Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 1.2.0

- Migrated `package:flutter/material.dart` and `package:flutter/cupertino.dart`
imports to `package:material_ui/material_ui.dart` (`^1.11.1`) and
`package:cupertino_ui/cupertino_ui.dart` (`^1.1.7`).
- Raised minimum SDK constraints to Dart `^3.13.0` and Flutter `>=3.47.0`.
- Updated the `vertex` example from `FirebaseAI.vertexAI()` to
`FirebaseAI.agentPlatform()`.

## 1.1.0

- **BREAKING CHANGE**: Suppressed Markdown images in `LlmMessageView` by default
Expand Down
7 changes: 3 additions & 4 deletions example/lib/callbacks/on_cancel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_ai_toolkit/flutter_ai_toolkit.dart';

// from `flutterfire config`: https://firebase.google.com/docs/flutter/setup
Expand All @@ -30,9 +30,8 @@ class ChatPage extends StatelessWidget {
const ChatPage({super.key});

void _onCancel(BuildContext context) {
ScaffoldMessenger.of(
context,
).showSnackBar(const SnackBar(content: Text('Chat cancelled')));
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text('Chat cancelled')));
}

@override
Expand Down
7 changes: 3 additions & 4 deletions example/lib/callbacks/on_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_ai_toolkit/flutter_ai_toolkit.dart';

// from `flutterfire config`: https://firebase.google.com/docs/flutter/setup
Expand All @@ -30,9 +30,8 @@ class ChatPage extends StatelessWidget {
const ChatPage({super.key});

void _onError(BuildContext context, LlmException error) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text('Error: ${error.message}')));
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('Error: ${error.message}')));
}

@override
Expand Down
2 changes: 1 addition & 1 deletion example/lib/cupertino/cupertino.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/cupertino.dart';
import 'package:cupertino_ui/cupertino_ui.dart';
import 'package:flutter_ai_toolkit/flutter_ai_toolkit.dart';

// from `flutterfire config`: https://firebase.google.com/docs/flutter/setup
Expand Down
2 changes: 1 addition & 1 deletion example/lib/custom_strings/custom_strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_ai_toolkit/flutter_ai_toolkit.dart';

import '../firebase_options.dart';
Expand Down
2 changes: 1 addition & 1 deletion example/lib/custom_stt/custom_stt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'package:cross_file/cross_file.dart';
import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_ai_toolkit/flutter_ai_toolkit.dart';

// from `flutterfire config`: https://firebase.google.com/docs/flutter/setup
Expand Down
62 changes: 30 additions & 32 deletions example/lib/custom_styles/custom_styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_ai_toolkit/flutter_ai_toolkit.dart';
import 'package:flutter_markdown_plus/flutter_markdown_plus.dart';
import 'package:google_fonts/google_fonts.dart';
Expand Down Expand Up @@ -86,35 +86,34 @@ class _ChatPageState extends State<ChatPage>
),
body: AnimatedBuilder(
animation: _animationController,
builder:
(context, child) => Stack(
children: [
SizedBox(
height: double.infinity,
width: double.infinity,
child: Image.asset(
'assets/halloween-bg.png',
fit: BoxFit.cover,
opacity: _animationController,
),
),
LlmChatView(
provider: _provider,
welcomeMessage:
'Welcome to the Custom Styles Example! Use the '
'butons on the action bar at the top right of the app to '
'explore light and dark styles in combination with normal '
'and Halloween-themed styles. Enjoy!',
suggestions: [
'I\'m a Star Wars fan. What should I wear for Halloween?',
'I\'m allergic to peanuts. What candy should I avoid at '
'Halloween?',
'What\'s the difference between a pumpkin and a squash?',
],
style: style,
),
builder: (context, child) => Stack(
children: [
SizedBox(
height: double.infinity,
width: double.infinity,
child: Image.asset(
'assets/halloween-bg.png',
fit: BoxFit.cover,
opacity: _animationController,
),
),
LlmChatView(
provider: _provider,
welcomeMessage:
'Welcome to the Custom Styles Example! Use the '
'butons on the action bar at the top right of the app to '
'explore light and dark styles in combination with normal '
'and Halloween-themed styles. Enjoy!',
suggestions: [
'I\'m a Star Wars fan. What should I wear for Halloween?',
'I\'m allergic to peanuts. What candy should I avoid at '
'Halloween?',
'What\'s the difference between a pumpkin and a squash?',
],
style: style,
),
],
),
),
);
}
Expand Down Expand Up @@ -156,10 +155,9 @@ class _ChatPageState extends State<ChatPage>
),
),
chatInputStyle: ChatInputStyle(
backgroundColor:
_animationController.isAnimating
? Colors.transparent
: Colors.black,
backgroundColor: _animationController.isAnimating
? Colors.transparent
: Colors.black,
decoration: BoxDecoration(
color: Colors.yellow,
border: Border.all(color: Colors.orange),
Expand Down
23 changes: 10 additions & 13 deletions example/lib/dark_mode/dark_mode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_ai_toolkit/flutter_ai_toolkit.dart';

import '../dark_style.dart';
Expand All @@ -26,8 +26,8 @@ class App extends StatelessWidget {
@override
Widget build(BuildContext context) => ValueListenableBuilder<ThemeMode>(
valueListenable: themeMode,
builder:
(BuildContext context, ThemeMode mode, Widget? child) => MaterialApp(
builder: (BuildContext context, ThemeMode mode, Widget? child) =>
MaterialApp(
title: title,
theme: ThemeData.light(),
darkTheme: ThemeData.dark(),
Expand Down Expand Up @@ -59,16 +59,13 @@ class _ChatPageState extends State<ChatPage> {
title: const Text(App.title),
actions: [
IconButton(
onPressed:
() =>
App.themeMode.value =
App.themeMode.value == ThemeMode.light
? ThemeMode.dark
: ThemeMode.light,
tooltip:
App.themeMode.value == ThemeMode.light
? 'Dark Mode'
: 'Light Mode',
onPressed: () =>
App.themeMode.value = App.themeMode.value == ThemeMode.light
? ThemeMode.dark
: ThemeMode.light,
tooltip: App.themeMode.value == ThemeMode.light
? 'Dark Mode'
: 'Light Mode',
icon: const Icon(Icons.brightness_4_outlined),
),
],
Expand Down
19 changes: 9 additions & 10 deletions example/lib/dark_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_ai_toolkit/flutter_ai_toolkit.dart';
import 'package:flutter_markdown_plus/flutter_markdown_plus.dart';
import 'package:google_fonts/google_fonts.dart';
Expand Down Expand Up @@ -133,15 +133,14 @@ SuggestionStyle _darkSuggestionStyle() {

const Color _greyBackground = Color(0xFF535353);

Color? _invertColor(Color? color) =>
color != null
? Color.from(
alpha: color.a,
red: 1 - color.r,
green: 1 - color.g,
blue: 1 - color.b,
)
: null;
Color? _invertColor(Color? color) => color != null
? Color.from(
alpha: color.a,
red: 1 - color.r,
green: 1 - color.g,
blue: 1 - color.b,
)
: null;

Decoration _invertDecoration(Decoration? decoration) => switch (decoration!) {
final BoxDecoration d => d.copyWith(color: _invertColor(d.color)),
Expand Down
Loading
Loading