In this recipe, after taking a picture, you will add a text recognition feature. Follow these steps:
- Import the latest version of the firebase_ml_vision package in your pubspec.yaml file:
firebase_ml_vision: ^0.10.0
- Create a new file in the lib folder of your project and call it ml.dart.
- Inside the new file, import the dart:io and firebase_ml_vision packages:
import 'dart:io';
import 'package:firebase_ml_vision/firebase_ml_vision.dart';
- Create a new class, calling it MLHelper:
class MLHelper {}
- In the MLHelper class, create a new async method, called textFromImage, that takes an image file and returns Future<String>:
Future<String> textFromImage(File image) async { }
- In the textFromImage method, process the image with the ML Kit TextRecognizer and return the retrieved text, as shown:
final FirebaseVision vision = FirebaseVision.instance;
final FirebaseVisionImage visionImage = FirebaseVisionImage...