ekyc_id_flutter 1.0.74
ekyc_id_flutter: ^1.0.74 copied to clipboard
A Flutter Plugin to interact with EkycID.
example/lib/main.dart
import 'package:ekyc_id_flutter/ekyc_id_flutter.dart';
import 'package:ekyc_id_flutter_example/test_result.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:permission_handler/permission_handler.dart';
// import 'package:ekyc_id_flutter/src/core/document_detection.dart';
import 'package:ekyc_id_flutter/src/document_scanner/document_scanner_values.dart';
import 'package:ekyc_id_flutter/src/core/models/object_detection_object_type.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
EkycIDServices.initialize(EkycURL(
ocrURL: "http://ocr.ekycsolutions.com",
faceCompareURL: "https://identity.ekycsolutions.com",
livenessURL: "http://liveness.ekycsolutions.com",
));
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> {
// var faceDetector = FaceDetectionController();
// var documentDetector = DocumentDetectionController();
@override
void initState() {
super.initState();
// documentDetector.initialize();
}
@override
Widget build(BuildContext context) {
final _faceScanner = GlobalKey<FaceScannerViewState>();
final _docScanner = GlobalKey<DocumentScannerViewState>();
final _livenessScanner = GlobalKey<LivenessDetectionViewState>();
Future<void> onFaceScanned(LivenessFace f) async {
await _faceScanner.currentState!.pause();
// await Navigator.push(context,
// MaterialPageRoute(builder: (_) => TestResult(image: f.image)));
await _faceScanner.currentState!.start();
}
Future<void> onDocScanned(
DocumentScannerResult f, DocumentScannerResult? b) async {
await _docScanner.currentState!.pause();
await Navigator.push(
context, MaterialPageRoute(builder: (_) => TestResult(document: f)));
await _docScanner.currentState!.start();
}
Future<void> onLivenessCompleted(LivenessDetectionResult liveness) async {
var result =
await EkycIDServices.instance.verifyLiveness(result: liveness);
// await _docScanner.currentState!.pause();
// await Navigator.push(
// context, MaterialPageRoute(builder: (_) => TestResult(document: f)));
// await _docScanner.currentState!.start();
}
return Scaffold(
// body: FaceScannerView(
// key: _faceScanner,
// options: FaceScannerOptions(
// useFrontCamera: true,
// ),
// onFaceScanned: onFaceScanned,
// overlayBuilder: (context, frameStatus, countdown) {
// return Column(
// children: [
// Text(frameStatus.toString()),
// Text(countdown.toString()),
// ],
// );
// },
// ),
// body: DocumentScannerView(
// key: _docScanner,
// onDocumentScanned: onDocScanned,
// options: DocumentScannerOptions(scannableDocuments: [
// ScannableDocument(
// mainSide: ObjectDetectionObjectType.NATIONAL_ID_0,
// secondarySide: ObjectDetectionObjectType.NATIONAL_ID_0_BACK,
// ),
// ScannableDocument(
// mainSide: ObjectDetectionObjectType.PASSPORT_KH_0,
// ),
// ScannableDocument(
// mainSide: ObjectDetectionObjectType.PASSPORT_INT,
// ),
// ]),
// overlayBuilder: (BuildContext context, FrameStatus frameStatus,
// DocumentSide side, int countDown) {
// return Container(
// child: Center(child: Text("$frameStatus, $side, $countDown")),
// );
// },
// ),
body: LivenessDetectionViewWithRandomPrompts(
key: _livenessScanner,
promptCount: 2,
onLivenessTestCompleted: onLivenessCompleted,
options: LivenessDetectionOptions(recordVideo: true),
overlayBuilder: (
context,
frameStatus,
countDown,
progress,
activePrompt,
isFocusing,
) {
return LivenessOverlayMinimal(
options: LivenessDetectionOptions(recordVideo: true),
frameStatus: frameStatus,
progress: progress,
promptTimer: countDown,
isFocusing: isFocusing,
activePrompt: activePrompt,
);
},
),
// body: LivenessDetectionView(
// key: _livenessScanner,
// onLivenessTestCompleted: onLivenessCompleted,
// options: LivenessDetectionOptions(recordVideo: true),
// overlayBuilder: (
// context,
// frameStatus,
// countDown,
// progress,
// activePrompt,
// isFocusing,
// ) {
// return LivenessOverlayMinimal(
// options: LivenessDetectionOptions(recordVideo: true),
// frameStatus: frameStatus,
// progress: progress,
// promptTimer: countDown,
// isFocusing: isFocusing,
// activePrompt: activePrompt,
// );
// },
// ),
);
}
}