facetec_flutter_plugin_demo 0.0.2 facetec_flutter_plugin_demo: ^0.0.2 copied to clipboard
Flutter plugin for FaceTec SDK. This is a demo plugin to show how connection can be established with the FaceTec SDK from a Flutter application. For full version of the plugin send an email to plugins [...]
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:facetec_flutter_plugin_demo/facetec_flutter_plugin_demo.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
String _message = "No message";
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
platformVersion = await FacetecFlutterPluginDemo.platformVersion;
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
}
registerPlugin() async {
String msg = await FacetecFlutterPluginDemo.initialize("ADD YOUR KEY HERE");
print(msg);
setState(() {
_message = msg;
});
}
getPluginStatus() async {
String msg = await FacetecFlutterPluginDemo.getSdkStatus;
setState(() {
_message = msg;
});
}
getPluginVersion() async {
String msg = await FacetecFlutterPluginDemo.getVersion;
setState(() {
_message = msg;
});
}
livenessCheck() async {
String msg = await FacetecFlutterPluginDemo.verify;
setState(() {
_message = msg;
});
}
enrollUser() async {
String msg = await FacetecFlutterPluginDemo.enroll("test");
setState(() {
_message = msg;
});
}
setServerUrl() async {
String zoomServerBaseURL = "https://api.zoomauth.com/api/v2/biometrics";
String msg = await FacetecFlutterPluginDemo.setServerUrl(zoomServerBaseURL);
setState(() {
_message = msg;
});
}
setPublicKey() async {
String publicKey = "-----BEGIN PUBLIC KEY-----\n" +
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5PxZ3DLj+zP6T6HFgzzk\n" +
"M77LdzP3fojBoLasw7EfzvLMnJNUlyRb5m8e5QyyJxI+wRjsALHvFgLzGwxM8ehz\n" +
"DqqBZed+f4w33GgQXFZOS4AOvyPbALgCYoLehigLAbbCNTkeY5RDcmmSI/sbp+s6\n" +
"mAiAKKvCdIqe17bltZ/rfEoL3gPKEfLXeN549LTj3XBp0hvG4loQ6eC1E1tRzSkf\n" +
"GJD4GIVvR+j12gXAaftj3ahfYxioBH7F7HQxzmWkwDyn3bqU54eaiB7f0ftsPpWM\n" +
"ceUaqkL2DZUvgN0efEJjnWy5y1/Gkq5GGWCROI9XG/SwXJ30BbVUehTbVcD70+ZF\n" +
"8QIDAQAB\n" +
"-----END PUBLIC KEY-----";
String msg = await FacetecFlutterPluginDemo.setPublicKey(publicKey);
setState(() {
_message = msg;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
children: [
Text('Running on: $_platformVersion\n'),
SizedBox(
height: 10,
),
Text(_message),
SizedBox(
height: 10,
),
RaisedButton(
onPressed: () {
registerPlugin();
},
child: Text(
"Register ZoomPlugin",
style: TextStyle(color: Colors.white),
),
color: Colors.green,
),
SizedBox(
height: 10,
),
RaisedButton(
onPressed: () {
getPluginStatus();
},
child: Text(
"Get ZoomPlugin Status",
style: TextStyle(color: Colors.white),
),
color: Colors.green,
),
SizedBox(
height: 10,
),
RaisedButton(
onPressed: () {
getPluginVersion();
},
child: Text(
"Get ZoomPlugin version",
style: TextStyle(color: Colors.white),
),
color: Colors.green,
),
SizedBox(
height: 10,
),
RaisedButton(
onPressed: () {
livenessCheck();
},
child: Text(
"Liveness check",
style: TextStyle(color: Colors.black),
),
color: Colors.yellow,
),
SizedBox(
height: 10,
),
RaisedButton(
onPressed: () {
enrollUser();
},
child: Text(
"Enroll User",
style: TextStyle(color: Colors.white),
),
color: Colors.red,
),
SizedBox(
height: 10,
),
RaisedButton(
onPressed: () {
setServerUrl();
},
child: Text(
"Set server url",
style: TextStyle(color: Colors.white),
),
color: Colors.green,
),
SizedBox(
height: 10,
),
RaisedButton(
onPressed: () {
setPublicKey();
},
child: Text(
"Set public key",
style: TextStyle(color: Colors.white),
),
color: Colors.green,
),
],
),
),
),
);
}
}