wya_do_flutter 2.0.3
wya_do_flutter: ^2.0.3 copied to clipboard
WYA Biometrics SDK for Flutter. Package supports iOS and Android to verify users identity.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:wya_do_flutter/wya_do_flutter.dart';
import 'dart:io' show Platform;
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _front = '';
String _back = '';
String _faceRecognition = '';
@override
void initState() {
super.initState();
}
Future<void> startSdk() async {
late String license;
late String faceRecognition;
late String front;
late String back;
if (Platform.isAndroid) {
// Android-specific key
license = 'androidLicenseKey';
} else if (Platform.isIOS) {
// iOS-specific key
license = 'iOSLicenseKey';
}
String result;
try {
result = await WyaDoFlutter.startCamera(
{'license': license, 'mode': 'SANDBOX', 'idType': 'ARG_3'});
final parsedJson = jsonDecode(result);
if (parsedJson['success']) {
faceRecognition = prettyJson(parsedJson['data']['validation']['faceRecognition']);
front = prettyJson(parsedJson['data']['front']);
back = prettyJson(parsedJson['data']['back']);
} else {
faceRecognition = prettyJson(parsedJson);
front = prettyJson(parsedJson);
back = prettyJson(parsedJson);
}
} on PlatformException {
faceRecognition = 'Failed';
front = 'Failed';
back = 'Failed';
}
setState(() {
_front = front;
_back = back;
_faceRecognition = faceRecognition;
});
}
String prettyJson(dynamic json) {
var spaces = ' ' * 4;
var encoder = JsonEncoder.withIndent(spaces);
return encoder.convert(json);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('WYA Plugin - example app'),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Center(
child: TextButton(
onPressed: startSdk,
child: Text('Iniciar SDK'),
),
),
Center(
child: Text('$_front'),
),
Center(
child: Text('$_back'),
),
Center(
child: Text('$_faceRecognition'),
),
],
),
),
);
}
}