A sample Flutter application for Gemma3 Edge-serving
This is a sample Flutter application demonstrating how to run Google's Gemma 3 (1B variant) language model entirely on an iOS device using the MediaPipe GenAI package. The app provides a simple chat interface for on-device inference with real-time, token-by-token streaming responses.
This repository serves as the practical, hands-on counterpart to our detailed Medium Article, which explains the development journey in more detail.
The goal of this project is to showcase a practical implementation of on-device AI. By running the LLM locally, the application benefits from:
- Privacy: User prompts are never sent to a server.
- Offline Capability: The core chat functionality works without an internet connection.
- Low Latency: Responses are generated directly on the device, reducing network delays.
- AI Model: Google Gemma 3 (
gemma3-1B-it-int4.task) - Flutter:
masterchannel (required for experimental features) - Inference Engine:
mediapipe_genai&mediapipe_corepackages - Platform: iOS (using a manually configured
Podfile)
This project relies on bleeding-edge features. Please follow these instructions carefully.
- Flutter SDK installed on the
masterchannel. - Xcode and CocoaPods for iOS development.
-
Clone the Repository
git clone https://github.com/KennethanCeyer/gemma3-chat-app.git cd gemma3-chat-app -
Download the Gemma 3 Model This project is configured to use the
gemma3-1B-it-int4.taskmodel.- Go to the model's official page on Kaggle: Gemma on Kaggle
- Download the
.taskfile. - Create an
assetsfolder in your project root and place the downloaded file inside. The final path must beassets/gemma3-1B-it-int4.task.
-
Configure Flutter This is a one-time command for this project.
flutter config --enable-native-assets
-
Install Dependencies First, get the Dart packages, then install the native iOS pods.
flutter pub get cd ios pod install cd ..
-
Run the App Make sure your iOS Simulator is running or a device is connected.
flutter run
The first launch will be slow as it copies the model file to the app's local storage. Subsequent launches will be much faster.
- Manual
Podfile: The current Flutter toolchain on themasterchannel does not automatically link the required native libraries for this package. We solved this by manually creating anios/Podfileand adding theMediaPipeTasksGenAIandMediaPipeTasksGenAICpods.
This project is licensed under the MIT License. See the LICENSE file for details.



