-
Notifications
You must be signed in to change notification settings - Fork 54
updating the flutter AI playground's behavior and layout #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Hey @apeynado, I'm not sure if you've contributed to this repository before, so just-in-case: this repository is lawless. If you feel good about the PR, feel free to merge it. Or if you want someone to review it, request it explicitly. |
|
Ah thanks! I'll have Khanh scan it to keep me honest! |
| Future<void> startCall() async { | ||
| // Initialize audio and video streams if they haven't been already. | ||
| if (!_audioIsInitialized) { | ||
| await _initializeAudio(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm why'd you move these out of of init state?
| class _DemoHomeScreenState extends State<DemoHomeScreen> { | ||
| int _selectedIndex = 0; | ||
| final GlobalKey<ChatDemoNanoState> _chatNanoKey = GlobalKey(); | ||
| bool _nanoPickerHasBeenShown = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These bits that are only relevant to specific demos (ex: Nano Banana chat) should probably be moved out into the Nano Banana demo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| const ChatDemo(), | ||
| const LiveAPIDemo(), | ||
| const MultimodalDemo(), | ||
| ChatDemoNano(key: _chatNanoKey), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this have a key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| } | ||
|
|
||
| void _onItemTapped(int index) { | ||
| if (index == 3 && !_nanoPickerHasBeenShown) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index == 3 is a magic number here, we'll want to refactor to reference a specific demo. We should also move the nanoPicker to the Nano Banana demo, that is probably not need in the main demo scaffolding!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, but the magic number still needs to be in the selector index...
| context, | ||
| ).colorScheme.primary, | ||
| ), | ||
| 'github.com/flutter/demos/issues', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this screen, where do we point users to a place to get help/file issues?
| demo.name, | ||
| style: TextStyle(fontWeight: FontWeight.bold), | ||
| bottomNavigationBar: BottomNavigationBar( | ||
| items: <BottomNavigationBarItem>[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can probably be refactored to be a little more module (have the BottomNavigationBar destinations be separate and iterate over it to create the list of BottomNavigationBarItem(s). It'll make it easier to add more demos in the future too.
| onDestinationSelected: _onItemTapped, | ||
| labelType: NavigationRailLabelType.all, | ||
| destinations: <NavigationRailDestination>[ | ||
| const NavigationRailDestination( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same this could probably reuse the same list of destinations for the mobile layout, but just loop over it and return NavigationRailDestinations instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| ), | ||
| ), | ||
| TextSpan(text: '.'), | ||
| TextSpan(text: '\n\n'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this addition makes the alert UI a little too cluttered & two CTAs distract from each other.
| @@ -0,0 +1,56 @@ | |||
| import 'package:firebase_ai/firebase_ai.dart'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we use this component anymore since we broke out the Nano Banana and Chat demos?
| @@ -0,0 +1,122 @@ | |||
| // Copyright 2025 Google LLC | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to duplicate this service from the original chat demo, it is identically the same business logic. We shouldn't have to duplicate code.
| @@ -0,0 +1,219 @@ | |||
| // Copyright 2025 Google LLC | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also duplicated code that doesn't need to be duplicated! We should eb able to use the original chat demo, just swap out the model in that is being used!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cleaned up the chat demo so it will focus on the function calling part and always select the gemini 2.5 flash. The majority of the UI component is moved to shared folder and reuse between two demos. I think it's ok to have independent demo page for different purposes.
Fixing Padding & UI & Adding Hamburger menu
| ), | ||
| Demo( | ||
| name: 'Multimodal Prompt', | ||
| description: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the index screen now means that the user has 0 context to what each demo is meant to showcase/feature. That'll be hard for them to then back-track and understand what APIs they should use in Firebase AI Logic.
| return LayoutBuilder( | ||
| builder: (context, constraints) { | ||
| if (constraints.maxWidth < 600) { | ||
| // Use BottomNavigationBar for smaller screens |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when the app gets scaled down, it regenerates the demo and re-executes the function call to change the app color. I don't think that's an intended effect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same with scaling up!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| 'Hey Gemini! Can you set the app color to purple?'; | ||
| WidgetsBinding.instance.addPostFrameCallback((_) { | ||
| opController.show(); | ||
| sendMessage(_userTextInputController.text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's a good idea to hijack the UI and automatically send the first message. As someone launching the demo for the first time, sending the message automatically kind of takes away the user's agency? Generally a bad UX pattern to execute an action without user consent. Maybe an alternative is to add a pop up or something that says "click send message" to see a tool call! or something that encourages the user to send the initial message, but still lets them decide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a dialog to ask the user to make the decision
| } | ||
| } | ||
|
|
||
| Future<ChatResponse> _handleFunctionCall( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think function calls are even supported in the nano banana models?
Pre-launch Checklist
Tested downloading the sample app from git and connecting it to firebase using flutterfire