Skip to content

Commit 12c84c0

Browse files
committed
Merge branch 'main' into a2a_dart
2 parents 48fcbbd + 10b950d commit 12c84c0

File tree

509 files changed

+15509
-2762
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

509 files changed

+15509
-2762
lines changed

.gemini/GEMINI.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ This document provides context for the Gemini Code Assistant to understand the `
44

55
## Project Overview
66

7-
This is a monorepo for a Generative UI SDK (`flutter_genui`). The SDK allows developers to add interactive, dynamic, and graphical UI to their applications, generated by a Large Language Model (LLM). Instead of rendering static text responses from an LLM, this SDK allows the LLM to compose UIs from a developer-provided widget catalog.
7+
This is a monorepo for a Generative UI SDK (`genui`). The SDK allows developers to add interactive, dynamic, and graphical UI to their applications, generated by a Large Language Model (LLM). Instead of rendering static text responses from an LLM, this SDK allows the LLM to compose UIs from a developer-provided widget catalog.
88

99
The project is structured as a monorepo containing several Dart and Flutter packages, along with example applications.
1010

1111
### Key Packages
1212

1313
| Package | Description |
1414
| ------------------------------------ | ----------------------------------------------------------------------- |
15-
| `packages/flutter_genui` | The core framework for employing Generative UI. |
16-
| `packages/flutter_genui_firebase_ai` | Firebase AI integration for `flutter_genui`. |
15+
| `packages/genui` | The core framework for employing Generative UI. |
16+
| `packages/genui_firebase_ai` | Firebase AI integration for `genui`. |
1717
| `packages/json_schema_builder` | A Dart JSON Schema package with validation, used by the core framework. |
1818

1919
### Example Applications
2020

21-
The `examples` directory contains sample applications demonstrating the usage of the `flutter_genui` SDK.
21+
The `examples` directory contains sample applications demonstrating the usage of the `genui` SDK.
2222

2323
| Example | Description |
2424
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
25-
| `simple_chat` | A minimal example of a conversational chat application. It demonstrates the fundamental concepts of `flutter_genui`, such as initializing the `GenUiConversation`, sending user messages, and rendering the AI-generated UI surfaces using the default core widget catalog. |
25+
| `simple_chat` | A minimal example of a conversational chat application. It demonstrates the fundamental concepts of `genui`, such as initializing the `GenUiConversation`, sending user messages, and rendering the AI-generated UI surfaces using the default core widget catalog. |
2626
| `travel_app` | A more advanced example of a travel planning assistant. It showcases dynamic UI generation, the use of a custom, domain-specific widget catalog, and how user interactions with the UI can be fed back to the AI to refine the conversation. |
2727
| `catalog_gallery` | A simple application that displays the widgets available in the catalog. It's a useful tool for developers to visualize the components that the AI can use to build UIs. |
2828

@@ -32,8 +32,8 @@ The `simple_chat` and `travel_app` examples are good starting points for underst
3232

3333
For a deeper understanding of the project's architecture and data flow, refer to the following documents:
3434

35-
- **`packages/flutter_genui/IMPLEMENTATION.md`**: Provides a comprehensive overview of the core `flutter_genui` package's architecture, purpose, and implementation.
36-
- **`examples/travel_app/IMPLEMENTATION.md`**: Describes the architecture and implementation of the `travel_app` example, showcasing how the `flutter_genui` package is used to build a dynamic, conversational UI.
35+
- **`packages/genui/IMPLEMENTATION.md`**: Provides a comprehensive overview of the core `genui` package's architecture, purpose, and implementation.
36+
- **`examples/travel_app/IMPLEMENTATION.md`**: Describes the architecture and implementation of the `travel_app` example, showcasing how the `genui` package is used to build a dynamic, conversational UI.
3737

3838
## Building and Running
3939

@@ -53,9 +53,9 @@ The project uses standard `flutter` and `dart` commands. A comprehensive script
5353

5454
### Code Style and Formatting
5555

56-
- The project follows the `dart_flutter_team_lints` linting rules, which is the combination of this [analysis_options.yaml](https://raw.githubusercontent.com/dart-lang/ecosystem/refs/heads/main/pkgs/dart_flutter_team_lints/lib/analysis_options.yaml) file and the [recommended](https://raw.githubusercontent.com/dart-lang/core/refs/heads/main/pkgs/lints/lib/recommended.yaml) and [core](https://raw.githubusercontent.com/dart-lang/core/refs/heads/main/pkgs/lints/lib/core.yaml) lints.
56+
- The project follows the linting rules in the `analysis_options.yaml` file at the top of the repo.
5757
- Code formatting is enforced using the `dart_format` tool.
58-
- The `tool/run_all_tests_and_fixes.sh` script should be run before committing to ensure all files are correctly formatted and analyzed.
58+
- The `tool/run_all_tests_and_fixes.sh` script should be run before committing to ensure all files are correctly formatted and analyzed. Don't run it every time you want to test something, just before you commit, since it does more than just test things, and takes a while.
5959

6060
### Testing
6161

@@ -70,15 +70,19 @@ The project uses standard `flutter` and `dart` commands. A comprehensive script
7070

7171
### Firebase Integration
7272

73-
- The examples and the `flutter_genui_firebase_ai` package use Firebase.
74-
- A script at `tool/stub_firebase_options.sh` is used in CI to create a stub `firebase_options.dart` file. For local development, developers need to configure their own Firebase project by following the instructions in `packages/flutter_genui/USAGE.md`.
73+
- The examples and the `genui_firebase_ai` package use Firebase.
74+
- A script at `tool/stub_firebase_options.sh` is used in CI to create a stub `firebase_options.dart` file. For local development, developers need to configure their own Firebase project by following the instructions in `packages/genui/USAGE.md`.
7575

76-
## Folder `spikes`
76+
## Updating the Guides (`packages/genui/.guides`)
7777

78-
The folder `spikes` contains experiments and proof of concepts,
79-
that does not have to be of good quality.
78+
When asked to update the developer guides located in `packages/genui/.guides`, it is critical to ensure the documentation accurately reflects the current state of the codebase. Before making any changes to the guides, you must read *all* the Dart code in the following packages:
8079

81-
Skip this folder when reviewing code.
80+
- `packages/genui`
81+
- `packages/genui_firebase_ai`
82+
- `packages/genui_google_generative_ai`
83+
- `packages/genui_a2ui`
84+
85+
This ensures that any code examples, API references, and architectural explanations in the guides are up-to-date and consistent with the actual implementation.
8286

8387
## Draft pull requests
8488

.gitignore

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
.svn/
1616
.swiftpm/
1717
migrate_working_dir/
18-
**/firepit-log.txt
19-
**/pglite-debug.log
18+
firepit-log.txt
19+
pglite-debug.log
2020

2121
# Diagrams, produced by https://pub.dev/packages/layerlens.
2222
DEPS.md
@@ -30,20 +30,20 @@ DEPS.md
3030
# Flutter/Dart/Pub related
3131
**/doc/api/
3232
**/ios/Flutter/.last_build_id
33-
**/.dart_tool/
34-
**/.flutter-plugins-dependencies
35-
**/.pub-cache/
36-
**/.pub/
37-
**/build/
38-
**/coverage/
39-
**/pubspec.lock
40-
**/generated_plugins.cmake
41-
**/GeneratedPluginRegistrant.*
42-
**/generated_plugin_registrant.*
43-
**/Podfile
44-
**/Podfile.lock
45-
**/Runner-Bridging-Header.h
46-
**/contents.xcworkspacedata
33+
.dart_tool/
34+
.flutter-plugins-dependencies
35+
.pub-cache/
36+
.pub/
37+
build/
38+
coverage/
39+
pubspec.lock
40+
generated_plugins.cmake
41+
GeneratedPluginRegistrant.*
42+
generated_plugin_registrant.*
43+
Podfile
44+
Podfile.lock
45+
Runner-Bridging-Header.h
46+
contents.xcworkspacedata
4747

4848
# Symbolication related
4949
app.*.symbols
@@ -57,13 +57,28 @@ app.*.map.json
5757
**/android/app/release
5858

5959
# Firebase
60-
**/google-services.json
60+
google-services.json
6161
**/lib/firebase_options.dart
62-
**/firebase.json
63-
**/GoogleService-Info.plist
64-
**/.firebase
65-
**/.firebaserc
62+
firebase.json
63+
GoogleService-Info.plist
64+
.firebase
65+
.firebaserc
6666

6767
# This package's specific logs.
68-
**/*.log.*
69-
**/*.log
68+
*.log.*
69+
*.log
70+
71+
# Python
72+
__pycache__/
73+
*.py[cod]
74+
*$py.class
75+
.venv
76+
venv/
77+
ENV/
78+
.env
79+
build/
80+
dist/
81+
*.egg-info/
82+
.pytest_cache/
83+
.coverage
84+
htmlcov/

CONTRIBUTING.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,33 @@ Triage issues ready for second-line review:
7878
At the end of a triage session, the untriaged issue list should be as close to
7979
empty as possible.
8080

81+
## Versioning
82+
83+
We use [Semver] for package versioning, although before 1.0.0, we will be
84+
incrementing only the minor number for breaking changes and the patch number for
85+
non-breaking changes. After 1.0.0, we will be using standard Semver, bumping the
86+
major number for breaking changes.
87+
88+
We release `genui`, `genui_firebase_ai`,
89+
`genui_google_generative_ui`, and `genui_a2ui` in lock step,
90+
with the same version number, so when one is released, they are all released.
91+
92+
`json_schema_builder` is released independently on its own schedule, with its
93+
own version number.
94+
95+
"Releasing" consititutes manually publishing them all to [pub.dev] after the
96+
pull request containing the version bump has passed CI. The packages must be
97+
published by someone with permission to publish under the labs.flutter.org
98+
owner.
99+
100+
Use the [release tool](tool/release/README.md) to help automate the process of
101+
releasing a new version.
102+
103+
[pub.dev]: https://pub.dev
104+
[Semver]: https://semver.org/
81105
[for-front-line]: https://github.com/flutter/genui/issues?q=is%3Aissue%20state%3Aopen%20-label%3AP0%20%20-label%3AP1%20-label%3AP2%20%20-label%3AP3%20-label%3Afront-line-handled
82106
[flutter_guidelines]: https://github.com/flutter/flutter/blob/master/CONTRIBUTING.md
83-
[usage_md]: packages/flutter_genui/USAGE.md#configure-firebase
107+
[usage_md]: packages/genui/USAGE.md#configure-firebase
84108
[assigned_p2_p3_issues]: https://github.com/flutter/genui/issues?q=is%3Aopen%20is%3Aissue%20label%3AP2%2CP3%20assignee%3A*
85109
[p0_p1_issues_without_milestone]: https://github.com/flutter/genui/issues?q=is%3Aopen%20is%3Aissue%20label%3AP1%2CP0%20no%3Amilestone
86110
[projectless_open_issues]: https://github.com/flutter/genui/issues?q=is%3Aopen%20is%3Aissue%20no%3Aproject

README.md

Lines changed: 35 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
# Generative UI SDK for Flutter (flutter_genui)
1+
# Generative UI SDK for Flutter (genui)
22

33
A Flutter library to enable developers to easily add interactive
44
generative UI to their applications.
55

6+
See the [Getting started with GenUI](https://www.youtube.com/watch?v=nWr6eZKM6no) video for an overview of the package.
7+
8+
[<img src="docs/assets/genui_intro_video_still.png" alt="GenUI Intro video still" height="500">](https://www.youtube.com/watch?v=nWr6eZKM6no)
9+
610
## Status: Highly Experimental
711

812
This is a highly experimental package, which means the API will change (sometimes drastically).
913
[Feedback is very welcome](https://github.com/flutter/genui/issues/new/choose).
1014

11-
## TL;DR
15+
## Summary
1216

1317
Our goal for the GenUI SDK for Flutter is to help you replace static "walls of text" from your LLM with
1418
dynamic, interactive, graphical UI.
@@ -37,63 +41,11 @@ chatbots and next-generation agent-based user experiences.
3741
- Create dynamically composed UIs: an agent can generate a complete form with sliders, date pickers,
3842
and text fields on the fly based on a user's request to "book a flight."
3943

40-
## Example
41-
42-
### Using the GenUI SDK with Firebase AI Logic
43-
44-
```dart
45-
// Adding your widgets into the catalog.
46-
// Start with the built-in catalog and add your own custom widgets.
47-
final catalog = CoreCatalogItems.asCatalog().copyWith([
48-
myCustomNewWidget,
49-
]);
50-
51-
/// Initializing the library.
52-
final genUiManager = GenUiManager(catalog: catalog);
53-
final contentGenerator = FirebaseAiContentGenerator(
54-
catalog: catalog,
55-
systemInstruction: '''
56-
You are a bicycle maintenance assistant who is an expert in diagnosing issues and
57-
giving step-by-step instructions.
58-
''',
59-
);
60-
late final _genUiConversation = GenUiConversation(
61-
genUiManager: genUiManager,
62-
contentGenerator: contentGenerator,
63-
onSurfaceAdded: _onSurfaceAdded,
64-
onSurfaceDeleted: (_) {},
65-
onTextResponse: (_) {},
66-
// ignore: avoid_print
67-
onWarning: (value) => print('Warning from GenUiConversation: $value'),
68-
);
69-
70-
// Put the surface, added by AI, to the list of messages that should be rendered,
71-
// trigger re-render, and scroll to bottom.
72-
void _onSurfaceAdded(SurfaceAdded surface) {
73-
if (!mounted) return;
74-
setState(() {
75-
_messages.add(MessageController(surfaceId: surface.surfaceId));
76-
});
77-
_scrollToBottom();
78-
}
79-
80-
// Render that UI.
81-
Widget build(BuildContext context) {
82-
if (type == MessageType.genUi) {
83-
return GenUiSurface(
84-
host: _genUiConversation.genUiManager.host,
85-
surfaceId: _surfaceId,
86-
onEvent: _handleEvent,
87-
);
88-
}
89-
}
90-
```
91-
9244
## Look & Feel
9345

9446
### Interactive [Travel App Example](examples/travel_app/)
9547

96-
<img src="misc/travel_app_genui_example.gif" alt="GenUI Travel App Demo" height="500">
48+
<img src="docs/assets/travel_app_genui_example.gif" alt="GenUI Travel App Demo" height="500">
9749

9850
_The GIF above shows how GenUI enables dynamic, interactive UI generation,_
9951
_instead of text descriptions or code from a traditional AI coding agent._
@@ -103,7 +55,7 @@ _instead of text descriptions or code from a traditional AI coding agent._
10355
This UI is not generated in the form of code; rather, it's generated at runtime
10456
based on a widget catalog from the developers' project.
10557

106-
<img src="misc/travel_app_genui_example.png" alt="GenUI Features Breakdown" height="600">
58+
<img src="docs/assets/travel_app_genui_example.png" alt="GenUI Features Breakdown" height="600">
10759

10860
## Implementation goals
10961

@@ -120,30 +72,43 @@ based on a widget catalog from the developers' project.
12072
- **Basic Layout:** LLM-driven basic layout generation.
12173
- **Any Model:** Integrate with any LLM that can generate structured JSON output.
12274

123-
## Some things we're thinking about
75+
## Connecting to an AI Agent
12476

125-
- **Genkit Integration:** Integration with Genkit.
126-
- **Expanded LLM Framework Support:** Official support for additional LLM frameworks.
127-
- **Streaming UI:** Support for progressively rendering UI components as they stream from the LLM.
128-
- **Full-Screen Composition:** Enable LLM-driven composition and navigation of entire app screens.
129-
- **A2A Agent Support:** Support for A2A agent interactions.
130-
- **Dart Bytecode:** Future support for Dart Bytecode for even greater dynamism and flexibility.
77+
The `genui` framework uses a `ContentGenerator` to communicate with a generative AI model,
78+
allowing `genui` to be backend agnostic. You can choose the implementation that best fits
79+
your needs, whether it's `FirebaseAiContentGenerator` for production apps,
80+
`GoogleGenerativeAiContentGenerator` for rapid prototyping, or `A2uiContentGenerator` for
81+
custom agent servers.
82+
83+
See the package table below for more details on each.
13184

13285
## Packages
13386

134-
| Package | Description |
135-
| ---------------------------------------------------------------- | ----------------------------------------------------------------------------- |
136-
| [flutter_genui](packages/flutter_genui/) | (work in progress) A framework to employ Generative UI. |
137-
| [flutter_genui_firebase_ai](packages/flutter_genui_firebase_ai/) | (work in progress) Firebase AI integration for flutter_genui. |
138-
| [json_schema_builder](packages/json_schema_builder/) | (work in progress) A fully featured Dart JSON Schema package with validation. |
87+
| Package | Description |
88+
| ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
89+
| [genui](packages/genui/) | The core framework to employ Generative UI. |
90+
| [genui_firebase_ai](packages/genui_firebase_ai/) | Provides **`FirebaseAiContentGenerator`** to connect to Gemini via Firebase AI Logic. This is the recommended approach for production apps based on client-side agents. |
91+
| [genui_google_generative_ai](packages/genui_google_generative_ai/) | Provides **`GoogleGenerativeAiContentGenerator`** for connecting to the Google Generative AI API with only an API key. Ideal for getting started quickly. |
92+
| [genui_a2ui](packages/genui_a2ui/) | Provides **`A2uiContentGenerator`** for connecting to any server that implements the [A2UI protocol](https://a2ui.org). Use this for integrating with custom agent backends. |
93+
| [json_schema_builder](packages/json_schema_builder/) | A fully featured Dart JSON Schema package with validation, used by the core framework to define widget data structures. |
13994

14095
## Usage
14196

142-
See [packages/flutter_genui/USAGE.md](packages/flutter_genui/USAGE.md).
97+
See [packages/genui/USAGE.md](packages/genui/USAGE.md).
14398

14499
## Constraints
145100

146-
This repo requires Flutter >=3.35.7.
101+
This repo requires Flutter version >=3.35.7.
102+
103+
## Some things we're thinking about
104+
105+
- **Genkit Integration:** Integration with Genkit.
106+
- **ADK Plugin:** turnkey integration with ADK.
107+
- **Expanded LLM Framework Support:** Official support for additional LLM frameworks.
108+
- **Streaming UI:** Support for progressively rendering UI components as they stream from the LLM.
109+
- **Full-Screen Composition:** Enable LLM-driven composition and navigation of entire app screens.
110+
- **A2A Agent Support:** Support for A2A agent interactions.
111+
- **Dart Bytecode:** Future support for Dart Bytecode for even greater dynamism and flexibility.
147112

148113
## Contribute
149114

analysis_options.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright 2025 The Flutter Authors.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
include: package:lints/recommended.yaml
6+
7+
analyzer:
8+
language:
9+
strict-casts: true
10+
strict-inference: true
11+
12+
linter:
13+
rules:
14+
# consistency
15+
- combinators_ordering
16+
- directives_ordering
17+
- lines_longer_than_80_chars
18+
- prefer_asserts_in_initializer_lists
19+
- prefer_const_constructors
20+
- prefer_relative_imports
21+
- prefer_single_quotes
22+
- sort_pub_dependencies
23+
- unnecessary_lambdas
24+
- unnecessary_library_directive
25+
- unnecessary_parenthesis
26+
- unnecessary_statements
27+
- use_is_even_rather_than_modulo
28+
29+
# correctness
30+
- always_declare_return_types
31+
- avoid_catching_errors
32+
- avoid_dynamic_calls
33+
- comment_references
34+
- conditional_uri_does_not_exist
35+
- only_throw_errors
36+
- test_types_in_equals
37+
- throw_in_finally
38+
- type_annotate_public_apis
39+
- unawaited_futures
40+
- unreachable_from_main
41+
42+
- omit_obvious_local_variable_types
43+
- specify_nonobvious_local_variable_types
44+
- specify_nonobvious_property_types
5.9 MB
Loading
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)