Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
74a8af4
feat(a2ui_flutter): add the framework adapter core
andrewkolos Oct 8, 2026
8bafd53
feat(a2ui_core): expose the v0.9 basic catalog's API
andrewkolos Oct 8, 2026
aa0ad11
feat(a2ui_flutter): add the v0.9 basic catalog
andrewkolos Oct 8, 2026
3ef0786
Merge remote-tracking branch 'upstream/main' into feat/flutter-adapte…
andrewkolos Oct 12, 2026
46a9772
Merge branch 'feat/flutter-adapter-core' into feat/flutter-adapter-ba…
andrewkolos Oct 12, 2026
71689fc
fix(a2ui_flutter): key a node's subtree by its implementation
andrewkolos Oct 12, 2026
bef448f
test(a2ui_flutter): cover A2uiSurface.of and maybeOf
andrewkolos Oct 12, 2026
f8edeaa
fix(a2ui_flutter): forward the basic catalog's protocol version and i…
andrewkolos Oct 12, 2026
119846f
Merge branch 'feat/flutter-adapter-core' into feat/flutter-adapter-ba…
andrewkolos Oct 12, 2026
7a97d94
refactor(a2ui_flutter): rename WidgetCatalog to CatalogImplementation
andrewkolos Oct 12, 2026
fab5147
Merge branch 'feat/flutter-adapter-core' into feat/flutter-adapter-ba…
andrewkolos Oct 12, 2026
2685d4f
refactor(a2ui_flutter): use CatalogImplementation in the basic catalog
andrewkolos Oct 12, 2026
effca52
feat(a2ui_flutter): apply a component's accessibility label and descr…
andrewkolos Oct 13, 2026
c2e6d9a
Merge branch 'feat/flutter-adapter-core' into feat/flutter-adapter-ba…
andrewkolos Oct 13, 2026
c00d8a6
fix(a2ui_flutter): adopt a2ui_core's renderer renames
andrewkolos Oct 14, 2026
8a9940c
Merge remote-tracking branch 'upstream/main' into feat/flutter-adapte…
andrewkolos Oct 14, 2026
e2dbf97
Merge branch 'fix/flutter-adapter-core-renames' into feat/flutter-ada…
andrewkolos Oct 14, 2026
9979705
fix(a2ui_flutter): use the http Apache license URL
andrewkolos Oct 14, 2026
6ca94a2
Merge branch 'fix/flutter-adapter-core-renames' into feat/flutter-ada…
andrewkolos Oct 14, 2026
8018e80
Merge remote-tracking branch 'upstream/main' into feat/flutter-adapte…
andrewkolos Oct 15, 2026
69c0ac8
docs(a2ui_flutter): match the README's a2ui_core constraint to the pu…
andrewkolos Oct 15, 2026
d855ffd
docs(a2ui_flutter): drop accessibility from the README's unsupported …
andrewkolos Oct 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion blueprints/codebases/dart/a2ui_flutter/codebase.blueprint.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ The Flutter renderer for the A2UI ecosystem, built on the node layer of `dart/a2

## **Local Technical Decisions & Overrides**

- **Package layout**: Folders follow the React adapter rather than the module blueprint's layout: the surface, node view, component API and props accessors are files in `lib/src/`, and there are no `surface/`, `nodes/`, `binding/` or `theme/` folders.
- **Package layout**: Folders follow the React adapter rather than the module blueprint's layout: the surface, node view, component API and props accessors are files in `lib/src/`, and there are no `surface/`, `nodes/`, `binding/` or `theme/` folders. The basic components are a library of their own, `package:a2ui_flutter/basic_catalog.dart`, in `lib/src/catalog/basic/`. They import neither the surface widget nor the node view, and read the surface model only through its ambient scope, to apply its theme and to report a write the data model rejects.
- **Basic catalog schemas**: Component schemas come from `a2ui_core`'s `BasicCatalog.v0_9()`, which is generated from the v0.9 basic catalog document, rather than being written by hand.

## **Validation & Execution Recipes**

Expand Down
68 changes: 62 additions & 6 deletions dart/a2ui_flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Flutter renderer for [A2UI](https://a2ui.org/) protocol v0.9. It renders the
surfaces of an `a2ui_core` `MessageProcessor` as widget trees, following the
[framework adapter blueprint](../../blueprints/modules/a2ui_framework_adapter.blueprint.md).

A component pairs a schema with a widget builder, and goes in a catalog of
the app's own.
The basic catalog is included. A custom component pairs a schema with a
widget builder, and goes in a catalog of the app's own.

## Installation

Expand All @@ -15,7 +15,7 @@ same commit, and keep the override:

```yaml
dependencies:
a2ui_core: ^0.2.2
a2ui_core: ^0.3.0
a2ui_flutter:
git:
url: https://github.com/a2ui-project/a2ui.git
Expand All @@ -39,7 +39,7 @@ a surface go back to the agent.

```dart
final processor = MessageProcessor<ComponentImplementation>(
catalogs: [demoCatalog],
catalogs: [basicCatalog()],
defaultVersion: A2uiProtocolVersion.v0_9,
);
final String version = A2uiProtocolVersion.v0_9.jsonValue;
Expand Down Expand Up @@ -96,16 +96,32 @@ ValueListenableBuilder(
processor.model.dispose();
```

- The basic components are Material widgets. Render surfaces under a
`MaterialApp` and inside a `Material`, such as a `Scaffold` body.
- Send `processor.getRendererDataModel()` as `a2uiClientDataModel` in the
transport metadata of each message to the agent, when it is not null.
- Key each surface's widget by `ObjectKey(surface)`, and remove it when the
surface is deleted.
- An `onError` listener can run while an `A2uiSurface` builds, so a
`setState` it causes must wait for the next frame.
- On macOS, network images and media need the
`com.apple.security.network.client` entitlement.

Models often write Markdown in Text. To render it, wrap the surface in an
`A2uiMarkdown` with a Markdown package's widget, such as `MarkdownBody` from
`flutter_markdown_plus`:

```dart
A2uiMarkdown(
builder: (context, markdown, style) => MarkdownBody(data: markdown),
child: A2uiSurface(surface: surface),
);
```

## Defining Custom Components

List your components in a `CatalogImplementation` under your own catalog id:
A v0.9 surface has one catalog, so list your components next to the basic
components and functions you need, under your own catalog id:

```dart
final rating = ComponentImplementation(
Expand Down Expand Up @@ -142,7 +158,10 @@ final rating = ComponentImplementation(

final demoCatalog = CatalogImplementation(
id: 'https://example.com/demo/catalog.json',
components: [rating],
components: [...BasicComponents.all, rating],
functions: BasicCatalog.v0_9().functions.values.toList(),
themeSchema: BasicComponents.api.themeSchema,
definitions: BasicComponents.api.definitions,
);
```

Expand Down Expand Up @@ -170,10 +189,47 @@ a `ChildWidgetBuilder`:
- Expect an unbounded height or width, as in a scroll view. Give a widget
that needs a bound, such as a `TextField`, one with a `LimitedBox`.

## Basic Catalog Components

`package:a2ui_flutter/basic_catalog.dart` implements the
[v0.9 basic catalog](../../specification/v0_9/catalogs/basic/catalog.json)
with Material widgets. `basicCatalog()` builds all of it, and
`BasicComponents` holds each component for a catalog of your own.

- **Layout**: `Row`, `Column`, `List`, `Card`, `Tabs`, `Modal`, `Divider`
- **Content**: `Text`, `Image`, `Icon`, `Video`, `AudioPlayer`
- **Input**: `Button`, `TextField`, `CheckBox`, `ChoicePicker`, `Slider`,
`DateTimeInput`

The components take the surface theme's `primaryColor` as the Material
theme's primary color. The functions format for the `locale` passed to
`basicCatalog()`, `en-US` by default.

Not supported yet:

- A literal `min` or `max` on DateTimeInput, which the `a2ui_core` validator
rejects.
- Measuring a surface's intrinsic size, as `IntrinsicWidth` and an
`AlertDialog`'s content do. Give the surface a fixed width there, or use a
`Dialog`.
- Leaving `video_player` out of an app. Video and AudioPlayer play through
it.

## Security

> [!IMPORTANT]
> Treat any agent outside your direct control as untrusted. Its messages and
> UI definitions are untrusted input: a malicious agent could imitate a
> legitimate interface to deceive users, or send layouts heavy enough to
> degrade the app.

`openUrl` fails unless the app passes a callback, such as `url_launcher`'s
`launchUrl`: `basicCatalog(openUrl: launchUrl)`. A bound `openUrl` call runs
whenever it resolves, not only on a tap, so with a callback the agent can open
an `http`, `https`, `mailto` or `tel` URL without the user acting. Pass one
only for an agent you trust.

## Tests

`test/catalog/basic/examples_test.dart` renders every
[v0.9 basic catalog example](../../specification/v0_9/catalogs/basic/examples).
19 changes: 19 additions & 0 deletions dart/a2ui_flutter/lib/basic_catalog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/// Implementations of the A2UI v0.9 basic catalog.
library;

export 'src/catalog/basic/basic_catalog.dart';
export 'src/catalog/basic/markdown.dart';
44 changes: 44 additions & 0 deletions dart/a2ui_flutter/lib/src/catalog/basic/audio_player.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:a2ui_core/a2ui_core.dart';
import 'package:flutter/material.dart';

import '../../component_implementation.dart';
import '../../component_props.dart';
import 'media.dart';

/// Builds the basic `AudioPlayer` component: its `description`, if any, above
/// playback controls for the audio at an `http` or `https` `url`.
Widget buildAudioPlayer(
BuildContext context,
ComponentNode<ComponentImplementation> node,
ComponentProps props,
ChildWidgetBuilder buildChild,
) {
final String? description = props.string('description');
return LimitedBox(
maxWidth: 300,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 4,
children: [
if (description != null && description.isNotEmpty)
Text(description, style: Theme.of(context).textTheme.bodySmall),
MediaPlayer(url: props.string('url')),
],
),
);
}
182 changes: 182 additions & 0 deletions dart/a2ui_flutter/lib/src/catalog/basic/basic_catalog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:a2ui_core/a2ui_core.dart';

import '../../component_implementation.dart';
import 'audio_player.dart';
import 'button.dart';
import 'card.dart';
import 'check_box.dart';
import 'choice_picker.dart';
import 'column.dart';
import 'date_time_input.dart';
import 'divider.dart';
import 'icon.dart';
import 'image.dart';
import 'list.dart';
import 'modal.dart';
import 'row.dart';
import 'slider.dart';
import 'tabs.dart';
import 'text.dart';
import 'text_field.dart';
import 'theme.dart';
import 'video.dart';

/// The v0.9 basic catalog: every basic component, and the functions of
/// [BasicCatalog.v0_9] formatting for [locale], under the basic catalog's id,
/// theme schema, title, description, protocol version and instructions.
///
/// An `openUrl` call, which fails without [openUrl], may run whenever a bound
/// property resolves, not only on a tap.
CatalogImplementation basicCatalog({
String locale = 'en-US',
OpenUrlCallback? openUrl,
}) => CatalogImplementation(
id: BasicCatalog.v0_9Id,
components: BasicComponents.all,
functions: BasicCatalog.v0_9(
locale: locale,
openUrl: openUrl,
).functions.values.toList(),
themeSchema: BasicComponents.api.themeSchema,
schemaId: BasicComponents.api.schemaId,
title: BasicComponents.api.title,
description: BasicComponents.api.description,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also forward protocolVersion and instructions from BasicComponents.api here to match BasicCatalog.v0_9() in a2ui_core?

protocolVersion: BasicComponents.api.protocolVersion,
instructions: BasicComponents.api.instructions,
definitions: BasicComponents.api.definitions,
);

/// The v0.9 basic catalog's component implementations.
abstract final class BasicComponents {
/// The basic catalog's specification: every component and function schema
/// and the theme schema.
static final CatalogApi api = BasicCatalog.v0_9();

/// The basic `AudioPlayer` component.
static final ComponentImplementation audioPlayer = _implement(
'AudioPlayer',
buildAudioPlayer,
);

/// The basic `Button` component.
static final ComponentImplementation button = _implement(
'Button',
buildButton,
);

/// The basic `Card` component.
static final ComponentImplementation card = _implement('Card', buildCard);

/// The basic `CheckBox` component.
static final ComponentImplementation checkBox = _implement(
'CheckBox',
buildCheckBox,
);

/// The basic `ChoicePicker` component.
static final ComponentImplementation choicePicker = _implement(
'ChoicePicker',
buildChoicePicker,
);

/// The basic `Column` component.
static final ComponentImplementation column = _implement(
'Column',
buildColumn,
);

/// The basic `DateTimeInput` component.
static final ComponentImplementation dateTimeInput = _implement(
'DateTimeInput',
buildDateTimeInput,
);

/// The basic `Divider` component.
static final ComponentImplementation divider = _implement(
'Divider',
buildDivider,
);

/// The basic `Icon` component.
static final ComponentImplementation icon = _implement('Icon', buildIcon);

/// The basic `Image` component.
static final ComponentImplementation image = _implement('Image', buildImage);

/// The basic `List` component.
static final ComponentImplementation list = _implement('List', buildList);

/// The basic `Modal` component.
static final ComponentImplementation modal = _implement('Modal', buildModal);

/// The basic `Row` component.
static final ComponentImplementation row = _implement('Row', buildRow);

/// The basic `Slider` component.
static final ComponentImplementation slider = _implement(
'Slider',
buildSlider,
);

/// The basic `Tabs` component.
static final ComponentImplementation tabs = _implement('Tabs', buildTabs);

/// The basic `Text` component.
static final ComponentImplementation text = _implement('Text', buildText);

/// The basic `TextField` component.
static final ComponentImplementation textField = _implement(
'TextField',
buildTextField,
);

/// The basic `Video` component.
static final ComponentImplementation video = _implement('Video', buildVideo);

/// Every basic component.
static List<ComponentImplementation> get all => [
audioPlayer,
button,
card,
checkBox,
choicePicker,
column,
dateTimeInput,
divider,
icon,
image,
list,
modal,
row,
slider,
tabs,
text,
textField,
video,
];

static ComponentImplementation _implement(
String name,
ComponentWidgetBuilder builder,
) => ComponentImplementation(
name: name,
schema: api.components[name]!.schema,
builder: (context, node, props, buildChild) => BasicTheme(
builder: (context) => builder(context, node, props, buildChild),
),
);
}
Loading
Loading