Menu

What I got wrong adding a typewriter to a streaming AI chat UI
πŸ“°

What I got wrong adding a typewriter to a streaming AI chat UI

DEV Community: dartΒ·Stephen ColorΒ·3 days ago
#82DRqIqA
#devtodart#devto#dev#streaming#reveal
Long article (1386 words) β€” no AI summary yet.
Reading 0:00
15s threshold

This is a follow-up to my earlier post, Streaming markdown in Flutter without the jitter . That one was about the parser side of StreamKit ( flutter_streaming_markdown_kit , my zero-dependency streaming chat UI kit). This one is about the layer above it: the typewriter reveal, the two things I got wrong in 1.0.0, and why handing the reveal to a TTS clock in 1.1.0 changed the controller's design. I won't re-explain the parsing here.

First, why a typewriter exists at all. Providers don't push text at a reading-friendly pace; tokens arrive in uneven bursts. Paint the raw text as it lands and the answer visibly jumps. Reveal at a fixed reading speed and nothing else, and a fast model leaves you permanently behind. The controller has to smooth the stream without drifting far from it.

The 1.0.0 design

TypewriterController extends ChangeNotifier , takes a TickerProvider ( vsync ), and has two config values: charsPerSecond = 320 and maxBacklogSeconds = 0.9 .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.