ChunhThanhDe/Flutter_gemini_Chat
This repository provides instructions for integrating Google Gemini into Flutter apps using the Flutter_gemini package. Here is an example of creating a Gemini Chat Bot ๐ฌ ๐ค AI using Flutter. Thanks for your support โค๏ธ
๐ Integrating Gemini into Your Flutter Application
Create gemini robot ๐ฌ chat bot ๐ค with Flutter. Show some โค๏ธ and star โญ the repo if you liked it.
contact for work, mail: chunhthanhde.dev@gmail.com
๐ Overview
Integrate Google's Gemini AI into your Flutter app with ease using the flutter_gemini package. This guide will help you enhance your app's functionality by leveraging Gemini's advanced AI features, including multilingual support, image and audio processing, and Natural Language Processing (NLP).
๐ Key Features of Gemini
- Stream Generate Content: Handle partial results with streaming without waiting for the complete response.
- Text-only Input: Complete and summarize texts using NLP.
- Text-and-Image Input: Use the gemini-pro-vision model for tasks involving both text and images.
- Multi-Turn Conversations (Chat): Engage in dynamic conversations with follow-up questions.
- Token Counting: Convert information into floating-point numbers.
- Model Info: Retrieve details about the model, including version and input token limits.
- EmbedContents and BatchEmbedContents: Transform information into numerical arrays for learning.
๐ Implementation Steps
-
Obtain an API Key ๐
Create an account at Google Gemini. -
Add Dependency ๐ฆ
- Add the
flutter_geminipackage to your project by running:flutter pub add flutter_gemini
- Add the
-
Initialize Gemini โ๏ธ
- In your
main.dartfile, initialize the Gemini package with your API key:void main() { Gemini.init(apiKey: 'YOUR_API_KEY_HERE'); runApp(const MyApp()); }
- In your
-
Create an Instance and Make Requests ๐ค
- Use the following code to create an instance of
flutter_geminiand handle text or image input:final _gemini = Gemini.instance; _gemini.textAndImage( text: 'Your query here', images: [imageFile.readAsBytesSync()], );
- Use the following code to create an instance of
-
Handle Responses ๐
- Manage responses from Gemini with attributes such as
FinishReasonandSafetyRating:if (value?.finishReason != 'STOP') { setResponse(value?.output ?? "Invalid User Query"); } if (value?.SafetyRating != 'HarmCategory') { setResponse(value?.candidates[0].safety_ratings); }
- Manage responses from Gemini with attributes such as
๐ Demo
You can see the response from the gemini here: https://www.youtube.com/watch?v=SUzw8YPLYZM
![]() |
![]() |
๐ Benefits
- Easy Integration: Simplifies adding AI features with clear documentation.
- Cross-Platform Compatibility: Supports Android, iOS, web, macOS, and Windows from a single codebase.
- Reduced Time to Market: Speeds up the integration of AI features into your app.
๐ Conclusion
Integrating Google Gemini into your Flutter app with the flutter_gemini package opens up new possibilities for enhancing user experience. Utilize Gemini's powerful AI capabilities to add multilingual support, process images and audio, and implement advanced chatbot functionality.
๐ References
Feel free to like and share your thoughts in the comments if you found this guide helpful! ๐







