GenUI SDK main components and concepts
Familiarize yourself with the main components and concepts of the Flutter for GenUI SDK.
Main components
#
The genui package is built around the following main components:
Conversation-
The primary facade and entry point for the package. It includes the
SurfaceControllerclass, manages the conversation history, and orchestrates the entire generative UI process. Catalog-
A collection of
CatalogItemobjects that defines the set of widgets that the AI is allowed to use. TheSurfaceControllersupports multiple catalogs, allowing you to organize your widgets into logical groups. EachCatalogItemspecifies a widget's name (for the AI to reference), a data schema for its properties, and a builder function to render the Flutter widget. DataModel-
A centralized, observable store for all dynamic UI state. Widgets are bound to data in this model. When data changes, only the widgets that depend on that specific piece of data are rebuilt.
A2uiTransportAdapter-
A bridge that parses raw text streams coming from your LLM into
A2uiMessagecommands for theSurfaceController. A2uiMessage-
A message sent from the AI (parsed by the
A2uiTransportAdapter) to the UI, instructing it to perform actions likecreateSurface,surfaceUpdate,dataModelUpdate, ordeleteSurface. SurfaceController-
Handles the processing of
A2uiMessages, manages theDataModel, and maintains the state of UI surfaces.
How it works
#The Conversation manages the interaction cycle:
-
User input
The user provides a prompt (for example, through a text field). The app calls
conversation.sendMessage(). -
AI invocation
The
Conversationsends the user's message to the LLM SDK. -
AI response
The LLM, guided by the widget schemas provided in its system prompt, sends back responses.
-
Stream handling
The text stream from the LLM SDK is fed into the
A2uiTransportAdapter. -
UI state update
A2uiMessagesparsed by the adapter are passed toSurfaceController.handleMessage(), which updates the UI state andDataModel. -
UI rendering
The
SurfaceControllerbroadcasts an update, and anySurfacewidgets listening for that surface ID will rebuild. Widgets are bound to theDataModel, so they update automatically when their data changes. -
Callbacks
Text responses and errors trigger callbacks on the
Conversationor are handled by your specific LLM integration flow. -
User interaction
The user interacts with the newly generated UI (for example, by typing in a text field). This interaction directly updates the
DataModel. If the interaction is an action (like a button click), theSurfacecaptures the event and forwards it to theSurfaceController, which automatically creates a newUserMessagecontaining the current state of the data model and restarts the cycle.
For more detailed information on the implementation of GenUI SDK for Flutter, check out the design doc.
The next section walks you through adding genui to your app.
Unless stated otherwise, the documentation on this site reflects Flutter 3.41.2. Page last updated on 2026-03-11. View source or report an issue.