Please note that the name of your app should be same in the Firebase, your project’s manifest.xml (if playing in android) and in the app-level build.gradle (if playing in android).

Face Detection using MLKit in Flutter….

Include the google-services.json in the app directory of android. (one of the steps in Firebase project setup).

VisionFace of MlKit library, is used for storing the parameters which are detected from the selected image.

VisionFaceDetectorOptions is used for setting any of the face detector’s default settings. The settings available are :

modeType : VisionFaceDetectorMode.Accurate / Fast

landmarkType : VisionFaceDetectorLandmark.All / None

classificationType : VisionFaceDetectorClassification.All / None

minFaceSize : a double value (with default as 0.1)

isTrackingEnabled : a boolean value (with default as false)

Next, create an instance of FirebaseVisionFaceDetector.

You can use the above settings with the instance of FirebaseVisionFaceDetector as

detector.detectFromBinary(_file?.readAsBytesSync(), options)

where detector is the instance of FirebaseVisionFaceDetector…

options is the settings of VisionFaceDetectorOptions…

Next, select the face using the floating action button. We are using the images from the device in this program, but we can anytime change it to select from camera by altering the source in the following line.