AiWidgetRegistry class

A name→widget allowlist for generative UI: the model emits a DataPart with a dataType discriminator and a JSON payload, and the registry maps it to a Flutter widget.

This is a deliberate allowlist — only registered dataTypes render (no reflection, no arbitrary instantiation), so a model can't conjure UI you didn't sanction. Unknown types fall back (see AiDataView).

Constructors

AiWidgetRegistry([Map<String, AiDataWidgetBuilder>? builders])
Creates a registry, optionally seeded with builders.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
types → Iterable<String>
The dataTypes with a registered builder.
no setter

Methods

build(BuildContext context, DataPart part) → Widget?
Builds the widget for part, or null if its dataType is not registered.
contains(String dataType) → bool
Whether a builder is registered for dataType.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
register(String dataType, AiDataWidgetBuilder builder) → AiWidgetRegistry
Registers builder for dataType, replacing any previous entry. Returns the registry for chaining.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited