Skip to content
26 changes: 18 additions & 8 deletions packages/firebase_ai/firebase_ai/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import 'pages/json_schema_page.dart';
import 'pages/schema_page.dart';
import 'pages/token_count_page.dart';
import 'pages/video_page.dart';
import 'pages/server_template_page.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
Expand Down Expand Up @@ -199,6 +200,11 @@ class _HomeScreenState extends State<HomeScreen> {
model: currentModel,
useVertexBackend: useVertexBackend,
);
case 11:
return ServerTemplatePage(
title: 'Server Template',
useVertexBackend: useVertexBackend,
);

default:
// Fallback to the first page in case of an unexpected index
Expand Down Expand Up @@ -227,18 +233,15 @@ class _HomeScreenState extends State<HomeScreen> {
style: TextStyle(
fontSize: 12,
color: widget.useVertexBackend
? Theme.of(context)
.colorScheme
.onSurface
.withValues(alpha: 0.7)
? Theme.of(context).colorScheme.onSurface.withAlpha(180)
: Theme.of(context).colorScheme.primary,
),
),
Switch(
value: widget.useVertexBackend,
onChanged: widget.onBackendChanged,
activeTrackColor: Colors.green.withValues(alpha: 0.5),
inactiveTrackColor: Colors.blueGrey.withValues(alpha: 0.5),
activeTrackColor: Colors.green.withAlpha(128),
inactiveTrackColor: Colors.blueGrey.withAlpha(128),
activeThumbColor: Colors.green,
inactiveThumbColor: Colors.blueGrey,
),
Expand All @@ -251,7 +254,7 @@ class _HomeScreenState extends State<HomeScreen> {
: Theme.of(context)
.colorScheme
.onSurface
.withValues(alpha: 0.7),
.withAlpha(180),
),
),
],
Expand All @@ -273,7 +276,7 @@ class _HomeScreenState extends State<HomeScreen> {
unselectedFontSize: 9,
selectedItemColor: Theme.of(context).colorScheme.primary,
unselectedItemColor: widget.useVertexBackend
? Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.7)
? Theme.of(context).colorScheme.onSurface.withAlpha(180)
: Colors.grey,
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
Expand Down Expand Up @@ -333,6 +336,13 @@ class _HomeScreenState extends State<HomeScreen> {
label: 'Live',
tooltip: 'Live Stream',
),
BottomNavigationBarItem(
icon: Icon(
Icons.storage,
),
label: 'Server',
tooltip: 'Server Template',
),
],
currentIndex: widget.selectedIndex,
onTap: _onItemTapped,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// 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:flutter/material.dart';
import 'package:firebase_ai/firebase_ai.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -65,11 +64,13 @@ class _ImagePromptPageState extends State<ImagePromptPage> {
var content = _generatedContent[idx];
return MessageWidget(
text: content.text,
image: Image.memory(
content.imageBytes!,
cacheWidth: 400,
cacheHeight: 400,
),
image: content.imageBytes == null
? null
: Image.memory(
content.imageBytes!,
cacheWidth: 400,
cacheHeight: 400,
),
isFromUser: content.fromUser ?? false,
);
},
Expand Down
Loading
Loading