![]() |
Currently, Artificial Intelligence is blooming all around. You must have heard about the ChatGPT, Bard and now Google has come up with a very new Artificial intelligence Gemini which responds to users in a truly human-like way. You can connect Google Gemini with Flutter in a very simple and quick way. Let’s learn how to do that. A sample video is given below to get an idea about what we are going to do in this article. Step By Step ImplementationStep 1: Create a New Project in Android StudioTo set up Flutter Development on Android Studio please refer to Android Studio Setup for Flutter Development, and then create a new project in Android Studio please refer to Creating a Simple Application in Flutter. Step 2: Add the package in flutterNow we will add the flutter_gemini package in this project. You can add the package using this command. Dart
Step 3: Create the Google API key and store it in dotenvTo create google gemini API key Click here and You can refer this article to store keys for env file. Step 4: We have 3 types to get the data through AI
Currently we will apply 2 functionality and we can select between one of them from Radio. We will use this using the radio button and select between to search with image or not. This are function which you will be require to search with gemini 1. Asking a question from AIDart
2. Sending Image and asking question related to itIn this we will understand how to ask gemini with our image. From Selection Image from your device you can refer to this article Gallery Access and Camera in Flutter Dart
You can use this function in your app as per your requirement. We have make a simple project where we can search from gemini through textfield. Brief Explanation about project:We have added 2 RadioButton to search either through text and image or through text. After that 1 material button is there where we will show what you have searched for after that result will be shown and at bottom we have added textfield where we will type our query and button to get result from gemini and if we have selected search with image then 1 more button for selecting image from device. We have added toast for validating the text and image are empty or not and loader when user is searching for data. Complete source code for sample project:Dart
Output:Search with Text:Search with text and image: |
Reffered: https://www.geeksforgeeks.org
Dart |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |