跪拜 Guibai
← Back to the summary

Flutter A2UI 1.0 Shrinks AI UI Token Use and Enforces Component Rules

Flutter recently officially released A2UI 1.0 and a2ui_flutter. The A2UI here is what Flutter GenUI uses. This time, the release seems to have addressed the engineering issues of AI-generated interfaces in one go:

But here I have to complain about the version. 1.0 is the A2UI protocol version, not the pub package version of a2ui_flutter. On pub.dev, a2ui_flutter is 0.4.0, a2ui_core is 0.8.0, and a2ui_agent is 0.4.0. These packages support protocol 1.0; that's really stupid.

For a scenario, the official example uses the dining app Commis. A normal page has recipe lists and filters, but the user asks directly "The host of Saturday's dinner is allergic to shellfish; does the menu need to change?" At that point the Agent can reason with the menu data and present an interactive card containing only replaceable dishes. The user doesn't need to go find a "shellfish allergy" filter option.

So GenUI fits scenarios where the interface structure needs to change along with the current question, such as one-off analysis cards, comparisons across multiple data sets, temporary approvals, and next-step actions. If you have fixed flows like login, settings, navigation, or ordinary forms, using A2UI brings little benefit.

And the model does not need to generate Dart code. It outputs structured descriptions like "put a Card here, inside it two Text widgets and a Button, bind the data to that field." The Flutter client then builds the interface with widgets already registered in the app.

This time the SDK is split clearly:

Component Responsibility
a2ui_agent Tells the model which Catalogs are available, parses Express or JSON, and compiles the result into A2UI messages.
a2ui_core MessageProcessor validates messages, manages Surface, component tree, Data Model, and function calls.
a2ui_flutter A2uiSurface maps validated components to Flutter Widgets.

Then in the old genui, SurfaceController is now replaced by MessageProcessor for interface state and validation. High-level wrappers like Conversation and Transport are also removed; apps manage chat history and network transport themselves.

For example, when the Agent sends createSurface, the client creates a UI area. Later updateComponents changes the component tree, updateDataModel changes data, and the Flutter Widgets bound to that data can update. At the same time, 1.0 supports carrying initial components and data directly in a single createSurface, so you don't need to split initialization into multiple messages.

Now Catalog, in addition to a component whitelist, can also restrict layout relationships. For example, even with the old Catalog, a developer could only provide pre-approved components to the Agent, like Text, Button, business charts. But restricting component types alone is not enough: the model might put a DataTable inside a button that only displays text and icons. The individual components are legal, but the combination is not.

So 1.0 adds allowedParents and allowedChildren to each component. For example, MyButton can only appear under a Row or Column, and can only have Text and Icon as children:

{
  "allowedParents": ["Row", "Column"],
  "allowedChildren": ["Text", "Icon"]
}

This part is supported in two layers:

But this actually only protects the UI structure. Whether a button can issue refunds or view medical records is business logic that cannot be validated in a Catalog.

Also, in 0.9, one Surface could only correspond to one Catalog. Previously, a business team that wanted to add custom charts had to manually merge base components with business components. In 1.0, one Surface can use multiple Catalogs at the same time; the Flutter side simply registers a list with MessageProcessor. Components in the protocol find their definitions via @catalogId or the Surface's default catalogId.

This way common components, finance charts, and user profile cards can be maintained separately. However, custom Widgets still have to be implemented on each target rendering end; a Catalog alone does not automatically generate native components for every platform.

Then there's Express to reduce JSON writing. Previously, describing a component meant repeatedly writing id, component, braces, and property names. The more components, the more tokens consumed by these fixed formats. Express changes the model output to a compact function-call style, and then the Agent SDK compiles it back to standard A2UI JSON, which improves size and performance at least.

According to tests, Express uses 46% fewer characters than compressed JSON. Using Gemini 3.8 Flash, 54 test samples, and Thinking disabled, the results are:

Metric Direct JSON Express
Median input tokens 10,980 6,000
Median code output tokens 807 297
Pass@1 53/54 53/54

That is, Express reduces output code tokens by 63% and prompt tokens by about 45%, but the number of one-shot passing samples is unchanged. After switching to Express, full dashboard generation time drops from 10 seconds to 5 seconds.

Finally, callAgentFunction addresses whether a click needs the LLM at all. The official portfolio example is classic: the user says "allocate $10,000 across BTC, ETH, and SOL," and the Agent organizes charts and multi-order editing cards. Once the page appears, there are two very different kinds of clicks:

Corresponding to Flutter code, the protocol wiring looks like this:

final processor = MessageProcessor<ComponentImplementation>(
  catalogs: [basicCatalog(), financeCatalog],
  outboundListener: sendToAgent,
  unifiedOutbound: true,
);

processor.processMessages(incomingJson);
final surface = processor.model.getSurface('order');
// In Widget build: when surface != null, use A2uiSurface(surface: surface)

Of course, the actual page also needs to listen to onSurfaceCreated and onSurfaceDeleted to add/remove interfaces, and then cancel subscriptions and call processor.dispose() when destroying.

outboundListener can also send click events, errors, and RPC messages back to the Agent. MessageProcessor manages the Surface state; the page just renders it. To actually connect to a backend, you still need transport, Catalog capability negotiation, and function handling.

The last new capability is metadata.extensions, which can attach extension fields to Surface, components, Catalog, and Actions. For example, you can pass a correlation token from a Python multi-agent backend to Flutter, have the app read it, write logs, and include the correlation info in subsequent Actions. This ties together one generation, rendering, and click. The main purpose is extension and tracing support.

The Agent side now also has a Dart a2ui_agent that can work with Genkit Dart. Python and TypeScript can also send A2UI 1.0.

Overall, A2UI's maturity is now fairly high. Combined with pre-generation, usability has improved a lot.

Compared with SSR and SDUI, the main role of A2UI is to unify the protocol and then connect to Agents, bringing this dynamic capability to Flutter's AOT scenario. Because the space in Catalogs is pre-built, there should be no major performance impact.