Flutter OCR means reading the words in a photo from inside a Flutter app. OCR stands for optical character recognition: software that turns the letters in a picture into text you can edit. On a phone you do not need a cloud service for it. Each platform already ships a text reader: Google's ML Kit on Android and Apple's Vision framework on iOS. Both read the photo on the device itself. You reach them in one of two ways: the google_mlkit_text_recognition plugin, or a small platform channel you write yourself. Below is the code for both, and why we moved one of our own Flutter apps from the plugin to its own channel.

You have a photo of a form, a receipt or a label, and you want its words in a text field. You do not want to upload the photo to read it. You also do not want a library that breaks your iOS build next year. You can have both. The choice between the two routes comes down to one file in your iOS folder: the Podfile.

Which Flutter OCR options run on the phone?

Two routes read the photo on the phone, and both end up in the same native engines:

Option Android iOS Scripts out of the box What you set up
The ML Kit plugin ML Kit ML Kit, installed through CocoaPods Latin, with Chinese, Devanagari, Japanese and Korean as extra packages One package, iOS 15.5 or newer, armv7 excluded in the Podfile
Your own platform channel ML Kit Apple Vision Latin on Android, with the other ML Kit scripts as extra libraries, and Vision's languages on iOS A Kotlin handler, a Swift handler and one Dart call

A "script" here is a writing system, such as Latin letters or Japanese characters.

The plugin is the faster start. Its own page explains that no machine learning runs in Dart. Every call passes through a platform channel to Google's native API. A platform channel is a named link that lets your Dart code call Kotlin on Android or Swift on iOS and get an answer back. The second route is the same idea, written by you, with Apple's own engine on iOS instead of Google's.

A cloud OCR service is a third route. The photo is uploaded and read on a server. Choose it only when the device cannot do the job, because the image then leaves the phone and every read costs a request.

How do you add OCR to a Flutter app with the ML Kit plugin?

Add the package:

flutter pub add google_mlkit_text_recognition 

Then read the text from an image file:

import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart'; Future<String> readText(String imagePath) async { final inputImage = InputImage.fromFilePath(imagePath); final recognizer = TextRecognizer(script: TextRecognitionScript.latin); try { final RecognizedText result = await recognizer.processImage(inputImage); return result.text; } finally { await recognizer.close(); } } 

The result also keeps the layout. result.blocks holds blocks of text, each with its lines and words, a bounding box (the rectangle around that text in the image), corner points and the languages recognised. Use the boxes when you need to know where on the page a value sat, for example the number printed beside "Total".

The plugin's page lists what each platform needs:

  • iOS: a minimum deployment target of iOS 15.5 (the oldest iOS version your app will install on), Xcode 15.3 or newer, and armv7 excluded. armv7 is the old 32-bit iPhone chip, and ML Kit supports only 64-bit devices. The page gives the Podfile lines that set both.
  • Android: a minSdkVersion of 21 or higher. That number is the oldest Android version your app supports.
  • Other scripts: Latin is the default. Chinese, Devanagari, Japanese and Korean each need an extra dependency: a Gradle line on Android and a pod on iOS.

Why move Flutter OCR off the plugin to your own channel?

Because of the Podfile. On iOS the plugin is installed through CocoaPods, the older package manager for iOS libraries, and it is set up in a file called the Podfile. The CocoaPods team announced a read-only plan for its trunk, the central list where new library versions are published: from 2 December 2026 it takes no new versions. Flutter's own documentation repeats the date.

Since release 3.44, Flutter turns on Swift Package Manager by default. Swift Package Manager is Apple's own way to add libraries to an app. Flutter falls back to CocoaPods for any plugin that does not support Swift Package Manager yet. So one CocoaPods-only plugin keeps the whole Podfile, and the whole CocoaPods toolchain, in your build.

That was our case. In October 2026 we moved I Save Life, our own Flutter blood donation app, to Swift Package Manager. Its text recognition plugin was CocoaPods-only on iOS, and the app used one call from it. We replaced the plugin with a native channel: Apple Vision on iOS, ML Kit text recognition 16.0.1 on Android, behind one Dart call. The iOS build now uses Swift Package Manager only, with no Podfile. We checked the change on iOS and Android devices.

There is a second gain on iOS. Vision's text recognition has been part of iOS since iOS 13, so the app ships no extra model for it. The model is the trained file that does the reading. On Android, Google's documentation gives the trade-off for ML Kit:

  • The bundled library ships the model inside your app. It adds about 4 MB per script per architecture (each processor type the app is built for), and it is ready at once.
  • The unbundled library adds about 260 KB. It downloads its model through Google Play services before first use.

How do you build the OCR platform channel?

You need three small pieces: one Dart call, and one handler for each platform. The channel name, app/text_recognition, must match in all three.

The Dart side

import 'package:flutter/services.dart'; class DeviceOcr { static const _channel = MethodChannel('app/text_recognition'); static Future<String> read(String imagePath) async { final text = await _channel.invokeMethod<String>('recognize', {'path': imagePath}); return text ?? ''; } } 

Wrap the call in a try block in your screen. Flutter's guide notes that a platform call can fail. A failed read should leave the field empty for the person to type in. It should never crash the form.

The Android side, with ML Kit

Add the bundled library to android/app/build.gradle.kts:

dependencies { implementation("com.google.mlkit:text-recognition:16.0.1") } 

Then handle the call in MainActivity.kt:

import android.net.Uri import com.google.mlkit.vision.common.InputImage import com.google.mlkit.vision.text.TextRecognition import com.google.mlkit.vision.text.latin.TextRecognizerOptions import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.engine.FlutterEngine import io.flutter.plugin.common.MethodChannel import java.io.File class MainActivity : FlutterActivity() { private val recognizer by lazy { TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS) } override fun configureFlutterEngine(flutterEngine: FlutterEngine) { super.configureFlutterEngine(flutterEngine) MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "app/text_recognition") .setMethodCallHandler { call, result -> val path = call.argument<String>("path") if (call.method != "recognize" || path == null) { result.notImplemented() return@setMethodCallHandler } try { val image = InputImage.fromFilePath(this, Uri.fromFile(File(path))) recognizer.process(image) .addOnSuccessListener { text -> result.success(text.text) } .addOnFailureListener { e -> result.error("ocr_failed", e.message, null) } } catch (e: Exception) { result.error("bad_image", e.message, null) } } } } 

process returns a task and calls you back when the read is done. So the handler returns at once, and the reply follows when the text is ready.

The iOS side, with Vision

New Flutter apps use the UIScene lifecycle, the way iOS now manages an app's windows. It has been the default since Flutter 3.41. Flutter's guide says to create the channel in didInitializeImplicitFlutterEngine, because the window does not exist yet when the app finishes launching. In AppDelegate.swift:

import Flutter import UIKit import Vision @main @objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate { func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) { GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry) let channel = FlutterMethodChannel( name: "app/text_recognition", binaryMessenger: engineBridge.applicationRegistrar.messenger() ) channel.setMethodCallHandler { call, result in guard call.method == "recognize", let args = call.arguments as? [String: Any], let path = args["path"] as? String else { result(FlutterMethodNotImplemented) return } DispatchQueue.global(qos: .userInitiated).async { let request = VNRecognizeTextRequest() request.recognitionLevel = .accurate request.usesLanguageCorrection = true let handler = VNImageRequestHandler(url: URL(fileURLWithPath: path)) do { try handler.perform([request]) let lines = (request.results ?? []).compactMap { $0.topCandidates(1).first?.string } DispatchQueue.main.async { result(lines.joined(separator: "\n")) } } catch { DispatchQueue.main.async { result(FlutterError(code: "ocr_failed", message: error.localizedDescription, details: nil)) } } } } } } 

The read runs on a background queue, away from the thread that draws the screen. The answer goes back to Flutter on the main queue. Each observation is one piece of recognised text, and topCandidates(1) takes the reading Vision rates highest. The lines are joined with line breaks and sent back as one string.

How do you get better OCR results on the device?

Most bad reads come from the photo, not the engine. Google's ML Kit guide gives numbers you can design the camera screen around:

Situation What the guide says
Size of each character At least 16 x 16 pixels, with no gain above 24 x 24
A business card filling the width A 640 x 480 image might work well
A letter-sized printed page A 720 x 1280 image might be needed
A blurred photo Accuracy drops: ask the person to take it again

On iOS, three settings on the Vision request do most of the work:

  • recognitionLevel chooses accuracy or speed.
  • recognitionLanguages lists the languages to try, in order of priority.
  • usesLanguageCorrection turns language correction on or off during recognition.

Language correction is built for words. Test it with your codes and reference numbers, and turn it off if it changes them.

Crop before you read. A photo of a whole desk with a slip in the middle gives the engine every other word on the desk too. You then have to find the right line among them.

What should your app do with the text after OCR?

Treat it as a draft. OCR reads characters, and a misread digit in a phone number is worse than an empty field.

In our app, the recognised text goes through a parser on the device before it fills the form. The parser never outputs a phone number or a blood group that is not in the text itself. A blood group read from handwriting is marked for the person to confirm. And the person still sends the form themselves.

On-device OCR keeps the reading step on the phone. If you then send the text or the photo to a server or an AI model, as many form-filling features do, say so in your privacy policy. The device step alone does not make the whole feature private.

Does Flutter OCR work on the web or desktop?

Not through ML Kit. The plugin's page says Google built ML Kit only for iOS and Android, and web or other platforms are not supported.

Vision is different. VNRecognizeTextRequest is available on macOS too, so a Flutter macOS app can call it through the same kind of channel you wrote for iOS. For the web or Windows you need another engine, and the choice depends on whether the reading can run on a server.

Quick answers about Flutter OCR

What is the best way to do OCR in Flutter?

On phones, use the engine each platform ships: ML Kit on Android and Vision on iOS. Both read printed text on the device with no charge per image. The ML Kit plugin is the quickest start. Your own platform channel suits apps that want Vision on iOS and no CocoaPods.

Does Flutter OCR work offline?

Yes, once the model is on the device. Vision's text recognition is part of iOS. On Android, the bundled ML Kit library ships the model inside the app, and the unbundled one downloads it through Google Play services before first use. After that, reading an image needs no network.

Can Flutter OCR read languages other than English?

ML Kit reads Latin script by default, and Chinese, Devanagari, Japanese and Korean with an extra dependency for each. Vision takes its languages from the recognitionLanguages setting, in order of priority, and can list the languages it supports. Results differ by script, so test with real photos in every language you need before release.

Originally published on Boffin Coders. If you would rather have on-device OCR built for you, you can hire Flutter developers who built it for an app of our own on Android and iOS.