ekyc_id_flutter 1.1.16
ekyc_id_flutter: ^1.1.16 copied to clipboard
A Flutter Plugin to interact with EkycID.
import 'package:ekyc_id_flutter/ekyc_id_flutter.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
EkycIDServices.initialize(EkycAPI(
apiKey: "",
apiURL: "",
));
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
Permission.camera.request();
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: HomeScreen(),
);
}
}
class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key);
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
LivenessDetectionResult? r;
final _livenessDetectionKey =
GlobalKey<LivenessDetectionViewWithRandomPromptsState>();
Future<void> onLivenessTestCompleted(LivenessDetectionResult res) async {
_livenessDetectionKey.currentState?.pause();
setState(() {
r = res;
});
var result = await EkycIDServices.instance.verifyLiveness(result: res);
print("verify result >> ${result.promptsMatch}");
_livenessDetectionKey.currentState?.refreshPrompts();
_livenessDetectionKey.currentState?.start();
}
Future<void> onDocumentScanned(DocumentScannerResult mainSide,
DocumentScannerResult? secondarySide) async {}
@override
Widget build(BuildContext context) {
var options = LivenessDetectionOptions(recordVideo: true);
return Scaffold(
body: Stack(
children: [
LivenessDetectionViewWithRandomPrompts(
key: _livenessDetectionKey,
options: options,
onLivenessTestCompleted: onLivenessTestCompleted,
),
if (r?.frontFace?.image != null)
Positioned(
left: 0,
top: 0,
child: Container(
color: Colors.red,
height: 100,
width: 100,
child: Image.memory(r!.frontFace!.image),
),
)
// Positioned.fill(
// child: DocumentScannerView(
// onDocumentScanned: onDocumentScanned,
// overlayBuilder: (context, frameStatus, currentSide, countDown) {
// return DocumentMinimalOverlay(
// options: DocumentScannerOptions(),
// frameStatus: frameStatus,
// currentSide: currentSide,
// showFlippingAnimation:
// frameStatus == FrameStatus.PROCESSING &&
// currentSide == DocumentSide.SECONDARY,
// );
// },
// ),
// // child: LivenessDetectionView(
// // options: options,
// // overlayBuilder: (
// // context,
// // frameStatus,
// // countDown,
// // progress,
// // activePrompt,
// // isFocusing,
// // ) {
// // return LivenessOverlayMinimal(
// // options: options,
// // frameStatus: frameStatus,
// // progress: progress,
// // promptTimer: countDown,
// // isFocusing: isFocusing,
// // activePrompt: activePrompt,
// // );
// // },
// // onLivenessTestCompleted: onLivenessTestCompleted,
// // ),
// ),
],
),
);
}
}