Is it possible to use Google ML-Kit On-Device Text Recognition in Flutter? All of the tutorials and resources I am finding online are all firebase_ml_vision
, but I am looking for one that uses the no-cost OCR from Google ML-Kit. How would I do this in Flutter?

- 5,031
- 17
- 33
- 41

- 137
- 1
- 12
-
Hi, there is no flutter plugin developed for the standalone ML Kit currently. There used to be one created for Firebase ML Kit on device Apis. You can check this to see if it still works: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_ml_vision/android/src/main/java/io/flutter/plugins/firebasemlvision – Chenxi Song Feb 09 '21 at 18:35
-
Hello, have a look at this flutter plugin: https://pub.dev/packages/google_ml_kit – MKapp Mar 06 '21 at 09:03
-
But is this package also available when deploying to the web, or just on mobile operating systems? – Unterbelichtet Jun 26 '21 at 19:13
4 Answers
as @Sayan Nath said you can use mlkit
, but I think the better choice would be google_ml_kit
, the firebase team who have worked on firebase_ml_vision also recommended using it.

- 46
- 2
- 4
Yes surely you can use this package https/pub.dev/packages/mlkit this is google's mlkit. OCR has also support for both ios and android. Happy Coding ;)

- 1,596
- 1
- 20
- 42

- 11
- 1
- 1
use this package https://pub.dev/packages/camera_google_ml_vision It's exactly the same in terms of how to use firebase_ml_vision

- 173
- 1
- 2
- 9
ML Kit for Text Recognition
Follow the installation of Google ML Kit (https://pub.dev/packages/google_ml_kit). (Flutter 2.8)
Set this thing up
bool hasImage = false;
File? image;
TextDetector textDetector = GoogleMlKit.vision.textDetector();
String? imagePath;
String scanText = '';
To get the image, use image picker: https://pub.dev/packages/image_picker
Future getImage(ImageSource source) async {
try {
final image = await ImagePicker().pickImage(source: source);
if (image == null) return;
final imageTemporary = File(image.path);
setState(() {
this.image = imageTemporary;
imagePath = imageTemporary.path;
debugPrint(imagePath);
hasImage = true;
});
} on PlatformException catch (e) {
debugPrint('Failed to pick image: $e');
}
}
Code for getting the text from the image
Future getText(String path) async {
final inputImage = InputImage.fromFilePath(path);
final RecognisedText recognisedText =
await textDetector.processImage(inputImage);
for (TextBlock block in recognisedText.blocks) {
for (TextLine line in block.lines) {
for (TextElement element in line.elements) {
setState(() {
scanText = scanText + ' ' + element.text;
debugPrint(scanText);
});
}
scanText = scanText + '\n';
}
}
}
Call the getText
function and pass the image path. getText(imagePath)
.

- 119
- 1
- 6