Ver-ID gives your users the ability to authenticate using their face.
The Ver-ID plugin has been tested to work with Flutter against the following compatibility matrix for iOS and Android. Please note that the SDK versions of the corresponding OSes are for compilation purposes (target iOS version on iOS and compile SDK version on Android):
Flutter Version | iOS | Android |
---|---|---|
1.20.4 (stable) | 10.3+ | SDK 21+ |
1.24.0-10.1.pre | 10.3+ | SDK 21+ |
2.2.3 (stable) | 10.3+ | SDK 21+ |
Other combinations may work, but your mileage may vary. Be sure to run the unit test suite in the example of the plugin to make sure the mobile OS platform combination you are using works before proceeding.
-
Request a License File and password for your app.
-
To install the plugin choose from one of the following four options:
-
If cloning from source (install/path/to/plugin is the directory created on the filesystem after you clone the repository):
git clone https://github.com/AppliedRecognition/Ver-ID-Flutter.git .
In your pubspec file under dependencies, add:
dependencies: veridflutterplugin: 'relative/path/to/plugin/directory'
-
Specify the path using your project's pubspec.yaml:
dependencies: veridflutterplugin: '>=1.0.0'
-
Specify the repository (master branch):
dependencies: veridflutterplugin: git: url: 'https://github.com/AppliedRecognition/Ver-ID-Flutter.git'
-
Specify the repository (custom branch or reference tag):
dependencies: veridflutterplugin: git: url: 'https://github.com/AppliedRecognition/Ver-ID-Flutter.git' ref: 'my_custom_branch or tag'
-
-
If your app includes the Android platform, ensure your app targets Android API level 21 or newer.
~~~xml <widget> <platform name="android"> <preference name="android-minSdkVersion" value="21" /> </platform> </widget> ~~~
Ver-ID must be loaded before you can run face detection sessions or compare faces.
The load operation may take up to a few of seconds. Load Ver-ID using the load
call:
VerID result;
// Platform messages may fail, so we use a try/catch with the PlatformException
try {
//platformVersion = await Veridflutterplugin.platformVersion;
result = await Veridflutterplugin
.load(); //.load('efe89f85-b71f-422b-a068-605c3f62603b');
pluginProcessResult = "VerID instance loaded successfully.";
} on PlatformException catch (ex) {
pluginProcessResult = 'Platform Exception: ' + ex.message.toString();
developer.log(ex.message.toString());
}
The Ver-ID Person plugin module will be available in your script from the import class VerID. The rest of the support classes can be imported from the main package via the route package:veridflutterplugin/src/ :
//method for user registration
Future<SessionResult> registerUser(String userId) async {
if (verID != null) {
RegistrationSessionSettings settings =
new RegistrationSessionSettings(userId: userId);
settings.showResult = true;
return VerID.register(settings: settings).then((value) {
if (value == null) {
throw 'Session canceled';
}
return value;
});
} else {
throw verIdNotInitialized;
}
}
Future<SessionResult> authenticate(String userId) async {
if (verID != null) {
AuthenticationSessionSettings settings =
new AuthenticationSessionSettings(userId: userId);
return VerID.authenticate(settings: settings).then((value) {
if (value == null) {
throw 'Session canceled';
}
return value;
});
} else {
throw verIdNotInitialized;
}
}
In a liveness detection session the user is asked to assume a series of random poses in front of the camera.
Liveness detection sessions follow the same format as registration and authentication.
if (verID != null) {
LivenessDetectionSessionSettings settings = new LivenessDetectionSessionSettings();
VerID.captureLiveFace(settings: settings).then((value) {
if (value == null) {
throw 'Session canceled';
}
return value;
});
} else {
throw verIdNotInitialized;
}
Similar to the above, with a couple of configuration options
Future<SessionResult> captureLiveFaceWithoutPoses() async {
if (verID != null) {
LivenessDetectionSessionSettings settings =
new LivenessDetectionSessionSettings();
// We only want to collect one result
settings.numberOfResultsToCollect = 1;
// Ask the user to assume only one bearing (straight)
settings.bearings = [Bearing.STRAIGHT];
return VerID.captureLiveFace(settings: settings).then((value) {
if (value == null) {
throw 'Session canceled';
}
return value;
});
} else {
throw verIdNotInitialized;
}
}
The callback of a successful session will contain an object that represents the result of the session.
Future<FaceComparisonResult> compareFaces(Face face1, Face face2) async {
if (verID != null) {
return VerID.compareFaces(face1: face1, face2: face2);
} else {
throw verIdNotInitialized;
}
}
Future<Face> detectFaceInImage(String imageData) async {
if (verID != null) {
return VerID.detectFaceInImage(image: imageData);
} else {
throw verIdNotInitialized;
}
}
Project samples can be found on the examples folder of this repository, to be used as a reference for development purposes.