r/FlutterDev • • 23d ago

Discussion Stop asking LLMs to do math in Generative UI

I have been watching a lot of recent Generative UI demos where an AI streams down an interactive card, like a recipe or an order summary. But as soon as the user drags a slider or edits an item count, the app ships the whole state back over a WebSocket to the remote model, burns a few hundred tokens computing basic arithmetic, and waits two seconds to repaint the text.

Making a remote AI call to multiply two numbers on a modern phone capable of billions of operations a second feels like an obvious trap.

Andrew Brogdon gave a great walkthrough on the Flutter channel recently about using client-side functions instead. Let the model generate the layout and bind expressions, but keep the deterministic math in local Dart code.

If you are building GenUI or dynamic form systems in Flutter, how are you handling local state updates and arithmetic right now? Are you handling it locally in your widget tree, or letting the agent do round-trips?

12 Upvotes

3 comments sorted by

5

u/puf 23d ago

Since you mention Andrew's recent video about the topic, here's the link: Client side functions for Flutter GenUI

2

u/RandalSchwartz 23d ago

Yeah, that's linked in the first paragraph of the article as well.

0

u/RandalSchwartz 23d ago

We ended up compiling registered client functions directly into synchronous computed() signals in bloc_signals_genui so calculations run in the exact same frame (0ms latency, zero microtasks).

If you want to see the full architectural breakdown, worked tests, and schema bindings, I wrote up a deep-dive featured on our publications page: https://blocsignal.dev/publications