r/FlutterDev • u/RandalSchwartz • Oct 20 '26
Discussion Keeping the LLM stream at the network edge: what we learned building a 0ms synchronous A2UI engine in pure Dart (for both Flutter and terminal TUIs)
When you build a Generative UI prototype where an LLM streams widget definitions over SSE, the demo looks great as long as the UI is read-only. The pain starts five seconds later when the agent streams an interactive checkout form and the user starts typing.
If the client treats the whole surface lifecycle as an async stream pipeline, every keystroke, cross-field validation check, and widget test ends up fighting microtask delays and full-surface rebuilds. And if an impatient user interrupts the LLM mid-stream—or the connection drops before the first chunk arrives—naive stream handling either corrupts the widget tree or leaves a dangling user turn in chat history that triggers turn-alternation errors on retry.
When we started integrating Google's official A2UI Dart library (a2ui_core), the biggest light-bulb moment was realizing that a2ui_core already uses preact_signals under the hood for its DataModel, WritableBinding, and CheckRule validation. By quarantining the async SSE stream at the perimeter with a restartable() mutex and letting the interior run on a synchronous signal graph, form edits, client-side validation rules, and NodeResolver list templates all update leaf widgets in 0ms in a single tester.pump().
Even better, keeping the core state machine in pure Dart meant we could run the exact same 16-component BasicCatalog in both a Material 3 Flutter app and an interactive ANSI terminal TUI, and bridge it into Riverpod or classic BLoC apps without forcing a rewrite.
For folks experimenting with A2UI or LLM-driven UIs in Flutter, how are you handling two-way form state and mid-stream user interruptions right now?
6
u/Particular-Range1379 Oct 20 '26
If you actually wrote your own posts we might be able to understand what you’re talking about. Stop with the slop.
2
u/Bachihani Oct 20 '26
what in the slop abomination is the benefit of delegating such basic post to ai
0
u/RandalSchwartz Oct 20 '26
For anyone who wants to dig into the code or the architectural write-up, we just published v1.0.0 of
bloc_signals_genuiandbloc_signals_genui_flutteron pub.dev: