ekyc_id_flutter 1.1.20
ekyc_id_flutter: ^1.1.20 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;
});
print("result >> ${res.frontFace?.headDirection}");
print("result >> ${res.leftFace?.headDirection}");
print("result >> ${res.rightFace?.headDirection}");
}
Future<void> onDocumentScanned(DocumentScannerResult mainSide,
DocumentScannerResult? secondarySide) async {
print("document >> ${mainSide.documentType}");
}
@override
Widget build(BuildContext context) {
var options = LivenessDetectionOptions(recordVideo: true);
return Scaffold(
body: Stack(
children: [
DocumentScannerView(
onDocumentScanned: onDocumentScanned,
options: DocumentScannerOptions(scannableDocuments: [
ScannableDocument(
mainSide: ObjectDetectionObjectType.NATIONAL_ID_0,
)
]),
overlayBuilder: (context, frameStatus, currentSide, countDown) {
return DocumentMinimalOverlay(
options: DocumentScannerOptions(scannableDocuments: [
ScannableDocument(
mainSide: ObjectDetectionObjectType.NATIONAL_ID_0,
)
]),
frameStatus: frameStatus,
currentSide: currentSide,
showFlippingAnimation: frameStatus == FrameStatus.PROCESSING &&
currentSide == DocumentSide.SECONDARY,
);
},
)
// LivenessDetectionView(
// 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),
// ),
// )
],
),
);
}
}