From 871baab8d0d59001f7ae37f80571474a3e6d7636 Mon Sep 17 00:00:00 2001 From: Michael Thomsen Date: Mon, 15 Dec 2025 11:06:29 +0100 Subject: [PATCH 1/2] Update README to reflect migration changes Removed migration notes for v0.9.0 and added a section for breaking changes and migration notes for v0.9.8. --- README.md | 120 +++--------------------------------------------------- 1 file changed, 5 insertions(+), 115 deletions(-) diff --git a/README.md b/README.md index 3aac6dd5..20011a51 100644 --- a/README.md +++ b/README.md @@ -34,121 +34,6 @@ provider integration: [Firebase AI][]. * **Cross-platform support:** Compatible with the Android, iOS, web, and macOS platforms. -## Migration to v0.9.0 - -The v0.9.0 release marks the first real breaking change since the initial -release of the Flutter AI Toolkit. This change was brought on by the migration -from the `google_generative_ai` and `firebase_vertexai` packages to the new -`firebase_ai` package. - -One change is that there is now a single `FirebaseProvider` that works for both -Gemini and Vertex. Both of these providers served the same models in the past, -e.g. `gemini-2.0-flash`, but did so via different mechanisms: one used an API -key and the other used a Firebase project. Another difference is the billing -model. When using the `firebase_ai` package, API key support has been dropped in -favor of always requiring a Firebase project. You can read about billing in the -Firebase docs: https://firebase.google.com/docs/ai-logic/get-started?platform=flutter&api=dev#set-up-firebase - -To migrate, the following code that uses the `GeminiProvider`: - -```dart -class ChatPage extends StatelessWidget { - const ChatPage({super.key, required this.title}); - final String title; - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: Text(title)), - body: LlmChatView( - provider: GeminiProvider( // this changes - model: GenerativeModel( // and this changes - model: 'gemini-2.0-flash', - apiKey: 'GEMINI-API-KEY', // and this changes - ), - ), - ), - ); - } -} -``` - -now becomes code that uses `googleAI()`: - -```dart -class ChatPage extends StatelessWidget { - const ChatPage({super.key}); - - @override - Widget build(BuildContext context) => Scaffold( - appBar: AppBar(title: const Text(App.title)), - body: LlmChatView( - provider: FirebaseProvider( // use FirebaseProvider and googleAI() - model: FirebaseAI.googleAI().generativeModel(model: 'gemini-2.0-flash'), - ), - ), - ); -} -``` - -And the following code that uses the `VertexProvider`: - -```dart -class ChatPage extends StatelessWidget { - const ChatPage({super.key}); - - @override - Widget build(BuildContext context) => Scaffold( - appBar: AppBar(title: const Text(App.title)), - body: LlmChatView( - provider: VertexProvider( // this changes - chatModel: FirebaseVertexAI.instance.generativeModel( // and this - model: 'gemini-2.0-flash', - ), - ), - ), - ); -} -``` - -becomes code that uses `vertexAI()`: - -```dart -class ChatPage extends StatelessWidget { - const ChatPage({super.key}); - - @override - Widget build(BuildContext context) => Scaffold( - appBar: AppBar(title: const Text(App.title)), - body: LlmChatView( - provider: FirebaseProvider( // use FirebaseProvider and vertexAI() - model: FirebaseAI.vertexAI().generativeModel(model: 'gemini-2.0-flash'), - ), - ), - ); -} -``` - -Also, all projects must now be initialized as Firebase projects, even those -using `googleAI()`: - -```dart -import 'package:firebase_ai/firebase_ai.dart'; -import 'package:firebase_core/firebase_core.dart'; -import 'package:flutter_ai_toolkit/flutter_ai_toolkit.dart'; - -// from `flutterfire config`: https://firebase.google.com/docs/flutter/setup -import '../firebase_options.dart'; - -void main() async { - WidgetsFlutterBinding.ensureInitialized(); - await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); - runApp(const App()); -} - -// now you can use FirebaseAI.googleAI() or FirebaseAI.vertexAI() -``` - ## Getting started @@ -286,6 +171,11 @@ examples. [example apps]: https://github.com/flutter/ai/tree/main/example/lib +## Breaking changes and migration + +The v0.9.8 release contained breaking changes. If you have code that uses +a version prior to that, please see [the migration notes](migration-notes.md). + ## Feedback As you use this package, please [log issues and feature requests][] as well as From e9e6d2dbd3a463e019282b3a7d2b00a9bb5f778c Mon Sep 17 00:00:00 2001 From: Michael Thomsen Date: Mon, 15 Dec 2025 11:07:39 +0100 Subject: [PATCH 2/2] Add migration notes for v0.9.0 breaking changes Document migration steps for breaking changes in v0.9.0, including code examples for transitioning from GeminiProvider and VertexProvider to FirebaseProvider with googleAI() and vertexAI(). --- migration-notes.md | 117 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 migration-notes.md diff --git a/migration-notes.md b/migration-notes.md new file mode 100644 index 00000000..68b3baa8 --- /dev/null +++ b/migration-notes.md @@ -0,0 +1,117 @@ +## Migration to v0.9.0 + +The v0.9.8 release contained breaking changes. For migration notes, +please see [migration-notes.md][]. + +The v0.9.0 release marks the first real breaking change since the initial +release of the Flutter AI Toolkit. This change was brought on by the migration +from the `google_generative_ai` and `firebase_vertexai` packages to the new +`firebase_ai` package. + +One change is that there is now a single `FirebaseProvider` that works for both +Gemini and Vertex. Both of these providers served the same models in the past, +e.g. `gemini-2.0-flash`, but did so via different mechanisms: one used an API +key and the other used a Firebase project. Another difference is the billing +model. When using the `firebase_ai` package, API key support has been dropped in +favor of always requiring a Firebase project. You can read about billing in the +Firebase docs: https://firebase.google.com/docs/ai-logic/get-started?platform=flutter&api=dev#set-up-firebase + +To migrate, the following code that uses the `GeminiProvider`: + +```dart +class ChatPage extends StatelessWidget { + const ChatPage({super.key, required this.title}); + final String title; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: Text(title)), + body: LlmChatView( + provider: GeminiProvider( // this changes + model: GenerativeModel( // and this changes + model: 'gemini-2.0-flash', + apiKey: 'GEMINI-API-KEY', // and this changes + ), + ), + ), + ); + } +} +``` + +now becomes code that uses `googleAI()`: + +```dart +class ChatPage extends StatelessWidget { + const ChatPage({super.key}); + + @override + Widget build(BuildContext context) => Scaffold( + appBar: AppBar(title: const Text(App.title)), + body: LlmChatView( + provider: FirebaseProvider( // use FirebaseProvider and googleAI() + model: FirebaseAI.googleAI().generativeModel(model: 'gemini-2.0-flash'), + ), + ), + ); +} +``` + +And the following code that uses the `VertexProvider`: + +```dart +class ChatPage extends StatelessWidget { + const ChatPage({super.key}); + + @override + Widget build(BuildContext context) => Scaffold( + appBar: AppBar(title: const Text(App.title)), + body: LlmChatView( + provider: VertexProvider( // this changes + chatModel: FirebaseVertexAI.instance.generativeModel( // and this + model: 'gemini-2.0-flash', + ), + ), + ), + ); +} +``` + +becomes code that uses `vertexAI()`: + +```dart +class ChatPage extends StatelessWidget { + const ChatPage({super.key}); + + @override + Widget build(BuildContext context) => Scaffold( + appBar: AppBar(title: const Text(App.title)), + body: LlmChatView( + provider: FirebaseProvider( // use FirebaseProvider and vertexAI() + model: FirebaseAI.vertexAI().generativeModel(model: 'gemini-2.0-flash'), + ), + ), + ); +} +``` + +Also, all projects must now be initialized as Firebase projects, even those +using `googleAI()`: + +```dart +import 'package:firebase_ai/firebase_ai.dart'; +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter_ai_toolkit/flutter_ai_toolkit.dart'; + +// from `flutterfire config`: https://firebase.google.com/docs/flutter/setup +import '../firebase_options.dart'; + +void main() async { + WidgetsFlutterBinding.ensureInitialized(); + await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); + runApp(const App()); +} + +// now you can use FirebaseAI.googleAI() or FirebaseAI.vertexAI() +```