Skip to main content
Guide · AI & LLM

On-Device AI in Flutter: ML Kit, LiteRT and Gemini Nano vs a Cloud LLM API

On-device AI in Flutter: when to pick ML Kit, LiteRT (TFLite) or Gemini Nano, which Flutter packages work today and when a cloud LLM API wins.

Afaq Zahir, author

Afaq Zahir

Flutter mobile product engineer

Published Updated 13 min read

On this page
  1. What counts as on-device AI in a Flutter app?
  2. On-device or cloud: which should your Flutter app use?
  3. Which on-device option fits which job?
  4. How does ML Kit work in Flutter?
  5. Is TensorFlow Lite now LiteRT, and which Flutter package should you use?
  6. Can a Flutter app use Gemini Nano?
  7. What about Apple's on-device model?
  8. Can you run open models like Gemma in Flutter?
  9. How do you design on-device first with a cloud fallback?
  10. What should you test before shipping an on-device AI feature?
  11. Frequently Asked Questions

Quick answer

Use on-device AI in Flutter for narrow tasks where data should stay on the phone, the feature must work offline or per-call cost matters, and keep a cloud LLM API for open-ended reasoning and for phones that cannot run a local model. ML Kit and LiteRT (the new name for TensorFlow Lite) cover ready-made vision tasks and custom models on Android and iOS. Gemini Nano through the ML Kit GenAI Prompt API is Android-only in Flutter today, so plan a cloud fallback.

Key takeaways

  • Three kinds of on-device AI reach a Flutter app: ML Kit's ready-made APIs, custom models run by LiteRT, and language models that ship with the phone (Gemini Nano on Android, Apple Foundation Models on iOS 26 and later).
  • TensorFlow Lite was renamed LiteRT on September 4, 2024, and the .tflite format did not change. flutter_litert says tflite_flutter is no longer maintained, while the tflite_flutter page shows no discontinued notice, so check both before you choose.
  • The google_mlkit_genai_prompt plugin is Android-only today, needs devices with AICore support and only runs while your app is in the foreground. Treat Gemini Nano as an enhancement with a cloud fallback.
  • flutter_gemma is discontinued and its pub.dev page points to flutter_edge_ai. The Flutter ML Kit plugins are community-maintained, not maintained by Google.
  • Firebase AI Logic hybrid inference is documented for iOS+, Android and Web. I found no Flutter page or firebase_ai changelog entry for it, so the on-device-first, cloud-fallback routing is your job.

On-device AI in Flutter means running a machine-learning model on the user's phone instead of sending their data to a server. A Flutter app can get it three ways: ML Kit's ready-made APIs, a custom model run by LiteRT (the new name for TensorFlow Lite), or a language model that ships with the phone, such as Gemini Nano on Android or Apple's Foundation Models on iOS. I checked the vendor docs and pub.dev pages on October 24, 2026, and several things older tutorials still teach are out of date.

What counts as on-device AI in a Flutter app?

Three families, with different maturity and different Flutter support:

  • ML Kit's ready-made APIs. Text recognition, barcode scanning, face detection, translation and similar tasks. Google says ML Kit's on-device processing "makes it fast and unlocks real-time use cases like processing of camera input" and that it "also works while offline" (ML Kit).
  • Your own model on LiteRT. You train or convert a .tflite model and run it through a Flutter package.
  • A language model on the phone. Gemini Nano on Android through ML Kit's GenAI APIs, Apple's Foundation Models on iOS, or an open model such as Gemma through a community runtime.

Flutter's own AI page lists Firebase AI Logic, Genkit Dart, the GenUI SDK and the Flutter AI Toolkit, but the page I read has no on-device section (Flutter docs). That is why most of this guide comes from vendor docs and pub.dev, not from Flutter's documentation. For the cloud side, see integrating ChatGPT, Gemini and Claude in Flutter.

On-device or cloud: which should your Flutter app use?

Use on-device models for narrow tasks where data should stay on the phone, the feature must work offline, or per-call cost matters. Use a cloud LLM for open-ended reasoning, long documents and the widest device coverage. Google's own guidance matches: Gemini Nano suits "use-cases where low cost and privacy safeguards are your primary concerns", and it warns about "token limits, device hardware limitations, and model capability boundaries" (Android Developers).

FactorOn-deviceCloud LLM API
PrivacyML Kit GenAI processes input, inference and output locally (docs). AICore "doesn't store any record of the input data or the resulting outputs" (docs).Every request leaves the device. Keep keys behind your own proxy (secure proxy guide).
LatencyNo network round trip, but "inference speed depends on device hardware" (docs).Adds a network round trip plus the provider's response time.
CostGoogle says on-device "reduces inference costs" (docs). Apple calls Foundation Models inference "free of cost" (Apple).Gemini API paid usage is billed per 1M tokens, after a free tier (pricing).
OfflineWorks without a network connection (docs).Needs a connection.
Model size and storageWith AICore, Google handles Gemini Nano's distribution and updates, with no impact on "your app's disk and runtime memory budget" (docs). A model you bundle or download yourself adds to your app or storage.Nothing on the device.
CapabilitySmall models with token limits. The Prompt API takes text or image plus text (docs).Frontier models, long context, tool use.
Device coverageGenAI APIs "will not support all Android devices" (plugin README).Any phone with a connection.
StabilityThe Prompt API is beta, "not subject to any SLA or deprecation policy" (docs).Provider APIs also change, so pin model versions.

Which on-device option fits which job?

OptionBest forFlutter package (pub.dev publisher)Platforms
ML Kit vision and language APIsFixed tasks: OCR, barcodes, faces, translationgoogle_mlkit_* (flutter-ml.dev)Android and iOS; a few are Android-only
ML Kit GenAI (summarize, proofread, rewrite, prompt)Short generative text on supported Android phonesgoogle_mlkit_genai_* (flutter-ml.dev)Android only
LiteRT (.tflite) custom modelsYour own trained or converted modelflutter_litert (hugo.ml) or tflite_flutter (tensorflow.org)Varies by package
Apple Foundation ModelsGenerative text on iOS 26 and laterCommunity bridges such as flutter_native_ai (pooka.app)iOS and macOS
Open models such as GemmaAn LLM you control, including on iOSflutter_edge_ai (sashadenisov.dev)Varies by engine

How does ML Kit work in Flutter?

Through community plugins. The google_mlkit_* family is published by flutter-ml.dev, and its pages say "This plugin is not sponsored or maintained by Google" and that ML Kit "was build only for mobile platforms: iOS and Android apps" (pub.dev). The README lists these plugins for both Android and iOS: barcode scanning, face detection, text recognition v2, image labeling, object detection and tracking, digital ink recognition, pose detection, selfie segmentation, language identification, on-device translation, smart reply and entity extraction. Face mesh detection, subject segmentation and the document scanner are Android-only (README).

The Fluently AI case study is a working example. It states that camera text recognition had to run offline on low-end smartphones without lagging the live preview, that the app used Google ML Kit Text Recognition to scan vocabulary from physical books and signs, and that recognition ran in under 100 milliseconds on-device. Pronunciation scoring in the same app went through the Whisper API, so the product combined on-device OCR with an API call for voice.

Before you pick an ML Kit API, read its page for whether the model ships inside your app or downloads on first use. That decides your app size and your first-run offline behavior.

Is TensorFlow Lite now LiteRT, and which Flutter package should you use?

Yes. Google renamed TensorFlow Lite to LiteRT on September 4, 2024. The .tflite format and file extension did not change, and "Apps that have already deployed TensorFlow Lite will not be affected" (Google Developers Blog). Today's LiteRT page calls it "Google's high-performance, cross-platform inference runtime for deploying models on edge devices", lists CPU, GPU and NPU backends, and supports export from PyTorch, TensorFlow and JAX into .tflite. It gives no benchmark figures, so measure on your own devices (LiteRT).

Two Flutter packages matter, and they disagree about maintenance:

PackagePublisherVersion when checkedPlatformsNotes
tflite_fluttertensorflow.org (verified)0.12.1Android, iOS, Linux, macOS, WindowsPublished about a year before I checked. No discontinued notice. The README calls it a work in progress and says its helper library is deprecated (pub.dev).
flutter_literthugo.ml (verified)3.9.4Android, iOS, Linux, macOS, web, WindowsBegan as a fork and says "tflite_flutter is no longer maintained". Not labeled as a Google package (pub.dev).

Neither page promises ongoing Google maintenance, so I would test your actual model on a mid-range phone before choosing, pin the version and keep the model file separate from the code. flutter_litert loads a model with Interpreter.fromAsset('model.tflite'). The tflite_flutter README says Android needs a minimum API level of 26.

Can a Flutter app use Gemini Nano?

On Android only, and only on devices with AICore. ML Kit's GenAI APIs "harness the power of Gemini Nano" and run on AICore, "an Android system service that enables on-device execution of GenAI foundation models" (ML Kit GenAI). The family covers summarization, proofreading, rewriting, image description, speech recognition and a general Prompt API. Summarization, proofreading, rewriting, image description and Prompt are beta, and speech recognition is alpha.

The Flutter plugin google_mlkit_genai_prompt says: "This API is currently only available on Android. iOS support may be added in the future." It needs minSdkVersion 26 and "devices with AICore support", and it is not maintained by Google (pub.dev). Plan for these documented limits:

  • Per-app quota. "Making too many GenAI API requests in a short period will result in an ErrorCode.BUSY response", and Google recommends exponential backoff. A longer-duration quota can also return PER_APP_BATTERY_USE_QUOTA_EXCEEDED.
  • Foreground only. Inference is allowed only while your app is the top foreground application, and a foreground service does not change that.
  • Model versions differ. Devices run different Gemini Nano versions (the page lists nano-v2, nano-v3 and nano-v4), and the same prompt can give different output on each.
  • Beta terms. The Prompt API may change in ways that break backward compatibility.

(ML Kit GenAI, Prompt API.) Google also says the Prompt API takes more effort than the task-specific ones because of prompt engineering and quality assurance, and recommends the task-specific APIs for standard jobs such as summarization.

Does Firebase AI Logic give Flutter an on-device fallback?

Not that I could find. The Android page recommends Firebase AI Logic's hybrid API to "automatically route requests to Gemini Flash or Gemini Pro models in the cloud when Gemini Nano is unavailable or unsupported". The hybrid docs list iOS+, Android and Web, with no Flutter entry, and the firebase_ai changelog (latest version 5.1.0 when I checked) has no mention of hybrid or on-device inference (Firebase, changelog). For the cloud half in Flutter, see building an AI chat screen with Firebase AI Logic.

What about Apple's on-device model?

Apple's Foundation Models framework lets developers "tap directly into the on-device foundation model" behind Apple Intelligence, with inference "free of cost", experiences "available when they're offline, and that protect their privacy", and native Swift support (Apple Newsroom). It is a Swift API, so Flutter needs a bridge. I found community plugins but no first-party one.

flutter_native_ai (pooka.app, version 0.5.4 when checked) wraps Apple Foundation Models on iOS and macOS and Gemini Nano through the ML Kit Prompt API on Android. Its page says Foundation Models "currently requires iOS 26.0 or macOS 26.0 or later at runtime" and "This package is pre-1.0. Apple Foundation Models and Gemini Nano APIs are new and may change" (pub.dev). A pre-1.0 community bridge is fine for a prototype. For production, expect to write and maintain a thin platform channel yourself if the package stalls.

Can you run open models like Gemma in Flutter?

Yes, through community runtimes, with a naming trap. flutter_gemma is discontinued: its final release (1.11.4) says it was replaced by flutter_edge_ai (pub.dev). flutter_edge_ai (sashadenisov.dev, version 2.5.2 when checked) is modular: you add only the engines you need, among them LiteRT-LM, MediaPipe, ONNX Runtime and llama.cpp. Its page makes no claim of being Google-official. The limits it documents are the kind that bite on real devices:

  • Anything backed by LiteRT needs minSdk 30 and is arm64-v8a only on Android.
  • On iOS, "a GPU .task does not load"; use a .litertlm model for the GPU, and the iOS Simulator runs on CPU only.
  • maxTokens covers the prompt, history and answer together.
  • MediaPipe's upstream is maintenance-only, so the page recommends .litertlm.

(pub.dev.) The page gives no model sizes, so check each model file's size before you decide to bundle or download it. Choose this route only if you need an LLM you control, or need one on iOS versions without Foundation Models, or on Android phones without AICore. The rename alone shows why you should pin versions.

How do you design on-device first with a cloud fallback?

Route through one interface, try the local model when the phone supports it, and fall back to your own backend on any failure. A failure includes a busy or quota error, a background call, a missing model or an unsupported phone. The sketch below is my own design, not a vendor API:

abstract class TextAi {
  Future<bool> get available;
  Future<String> summarize(String text);
}

class AiRouter {
  AiRouter({required this.cloud, this.onDevice});

  final TextAi? onDevice; // null on iOS before iOS 26 and on unsupported phones
  final TextAi cloud; // calls your own proxy, never a key shipped in the app

  Future<String> summarize(String text) async {
    final local = onDevice;
    if (local != null && await local.available) {
      try {
        return await local.summarize(text);
      } catch (_) {
        // busy, quota, background or model errors: use the cloud instead
      }
    }
    return cloud.summarize(text);
  }
}

Three rules keep this honest. First, the cloud side stays behind your proxy with App Check, as in the secure proxy guide. Second, send the cloud model only what it needs. Google suggests using ML Kit Text Recognition to extract text from an image first (Prompt API), which also means the model can receive text instead of the raw image. Third, tell users when a result came from the cloud if your privacy copy promises local processing.

What should you test before shipping an on-device AI feature?

  1. Real devices, including low-end ones. Simulators can mislead: the iOS Simulator runs open models on CPU only. Profile with the steps in Flutter performance tips.
  2. Unsupported phones. Confirm the cloud fallback fires when AICore or Foundation Models is missing.
  3. Quota and background behavior. Trigger BUSY-style failures and call from the background, then check the fallback.
  4. First-run model state. Test with no model yet downloaded and with no connection.
  5. Output differences. Gemini Nano versions can answer the same prompt differently, so test prompts on more than one device generation.
  6. Dependency risk. Pin versions, note each package's publisher and review its pub.dev page again before every release.

Frequently Asked Questions

Can Flutter run Gemini Nano on an iPhone?

No. Gemini Nano runs through Android's AICore, and the google_mlkit_genai_prompt plugin states the API is currently only available on Android (pub.dev). On iPhone, the equivalent is Apple's Foundation Models framework on iOS 26 and later, reached through a community bridge.

Is TensorFlow Lite deprecated?

It was renamed. Google's blog says TensorFlow Lite is now LiteRT, the .tflite format is unchanged and deployed apps are unaffected (Google Developers Blog). What changed for Flutter is the package situation: flutter_litert says tflite_flutter is no longer maintained.

Is tflite_flutter still maintained?

Its pub.dev page shows no discontinued notice, but it shows version 0.12.1 published about a year before I checked and a README that calls the project a work in progress (pub.dev). The flutter_litert page says it is no longer maintained (pub.dev). Test your model with both before you commit.

Are the Flutter ML Kit plugins official Google packages?

No. The plugin pages say "This plugin is not sponsored or maintained by Google" (pub.dev). They wrap Google's native ML Kit, which targets iOS and Android only.

Does ML Kit work offline?

Google says ML Kit's on-device processing "also works while offline" (ML Kit). Check each API's page for whether its model ships with your app or downloads on first use.

Is on-device AI free?

There is no per-call server bill, and Google says on-device AI "reduces inference costs" (Android Developers). Apple calls Foundation Models inference "free of cost" (Apple). You still pay in engineering time, model storage if you bundle models and testing across devices.

Do I still need a backend proxy if I use on-device AI?

Yes, whenever any path calls a cloud model. A cloud fallback needs the same protection as any LLM call: keys on the server, authenticated requests and App Check. See the secure proxy guide.

What should a startup pick first?

Start with the cloud API behind a proxy, because it works on every phone and is the fastest to ship. Add ML Kit for fixed tasks like OCR or barcodes where speed and offline use matter, and add Gemini Nano or Foundation Models later as an optional upgrade with a fallback.

Want an on-device or hybrid AI feature built into your Flutter app, with a tested cloud fallback? See my Flutter AI development service or read how I build Flutter apps with AI in 2026.

Afaq Zahir

Written by

Afaq Zahir

Flutter mobile product engineer with 4+ years shipping 20+ apps to the App Store and Google Play. Led Flutter teams at Metasense and Apptex.

GitHub ↗LinkedIn ↗Last reviewed
Book a call