streaming/reveal_engine library

The arithmetic behind the streaming reveal.

Deliberately free of Flutter: it owns counters, the widget owns the Ticker and calls setState. That split keeps the pacing rules — which are the fiddly part — testable without pumping a widget.

Three behaviours a naive typewriter gets wrong, and this does not:

  • Lag adaptation. A model can emit faster than the reveal speed. Left alone the animation falls further behind for the whole reply. Whenever the backlog would take longer than maxLagSeconds to clear, the reveal speeds up to clear it in that window instead.
  • Fast-forward. When the stream ends there is nothing left to wait for, so the remainder lands within fastForwardSeconds rather than trickling at the baseline rate.
  • Replacement. A regenerate or branch switch replaces the text rather than extending it, and must restart rather than continue from a meaningless offset.

Classes

RevealEngine
Counters for a character-by-character reveal.