Usage
To use this plugin, add firebase_ml_vision
as a dependency in your pubspec.yaml file. You must also configure Firebase for each platform project: Android and iOS (see the example folder or https://codelabs.developers.google.com/codelabs/flutter-firebase/#4 for step by step details).
Android
If you're using the on-device ImageLabeler
, include the latest matching ML Kit: Image Labeling dependency in your app-level build.gradle file.
android {
dependencies {
// ...
api 'com.google.firebase:firebase-ml-vision-image-label-model:17.0.2'
}
}
If you're using the on-device Face Contour Detection
, include the latest matching ML Kit: Face Detection Model dependency in your app-level build.gradle file.
android {
dependencies {
// ...
api 'com.google.firebase:firebase-ml-vision-face-model:17.0.2'
}
}
If you receive compilation errors, try an earlier version of ML Kit: Image Labeling.
Optional but recommended: If you use the on-device API, configure your app to automatically download the ML model to the device after your app is installed from the Play Store. To do so, add the following declaration to your app's AndroidManifest.xml file:
<application ...>
...
<meta-data
android:name="com.google.firebase.ml.vision.DEPENDENCIES"
android:value="ocr" />
<!-- To use multiple models: android:value="ocr,label,barcode,face" -->
</application>
iOS
Versions 0.7.0+
use the latest ML Kit for Firebase version which requires a minimum deployment
target of 9.0. You can add the line platform :ios, '9.0'
in your iOS project Podfile
.
If you're using one of the on-device APIs, include the corresponding ML Kit library model in your
Podfile
. Then run pod update
in a terminal within the same directory as your Podfile
.
pod 'Firebase/MLVisionBarcodeModel'
pod 'Firebase/MLVisionFaceModel'
pod 'Firebase/MLVisionLabelModel'
pod 'Firebase/MLVisionTextModel'