Catalog class interface

Represents a collection of UI components that a generative AI model can use to construct a user interface.

A Catalog serves three primary purposes:

  1. Holds a list of CatalogItems, which define the available widgets.
  2. Holds a list of ClientFunctions, which define available functions.
  3. Provides a mechanism to build a Flutter widget from a JSON-like data structure (JsonMap).
  4. Dynamically generates a Schema that describes the structure of all supported widgets and functions, which can be provided to the AI model.
  5. Provides instructions for the generated UI, which should be incorporated into the system prompt.
Annotations

Constructors

Catalog(Iterable<CatalogItem> items, {Iterable<ClientFunction> functions = const [], String? catalogId, List<String> systemPromptFragments = const []})
Creates a new catalog with the given list of items.
const

Properties

catalogId String?
A string that uniquely identifies this catalog.
final
definition → Schema
A dynamically generated Schema that describes all widgets in the catalog.
no setter
fullSchema → Schema
A dynamically generated Schema representing the catalog, including all custom components, functions, and specification defs.
no setter
functions Iterable<ClientFunction>
The list of ClientFunctions available in this catalog.
final
hashCode int
The hash code for this object.
no setterinherited
items Iterable<CatalogItem>
The list of CatalogItems available in this catalog.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
systemPromptFragments List<String>
Instructions for UI generation.
final

Methods

buildWidget(CatalogItemContext itemContext) Widget
Builds a Flutter widget from a JSON-like data structure.
copyWith({List<CatalogItem>? newItems, List<ClientFunction>? newFunctions, String? catalogId, List<String>? systemPromptFragments}) Catalog
If an item or function with the same name already exists in the catalog, it will be replaced with the new one.
copyWithout({Iterable<CatalogItem>? itemsToRemove, Iterable<ClientFunction>? functionsToRemove, String? catalogId, List<String>? systemPromptFragments}) Catalog
Returns a new Catalog instance containing the items from this catalog with the specified items removed.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toCapabilitiesJson() JsonMap
Generates a JSON map suitable for inclusion in an inline catalog array within A2UiClientCapabilities.
toString() String
A string representation of this object.
inherited

Operators

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