ekyc_id_flutter 1.0.55 copy "ekyc_id_flutter: ^1.0.55" to clipboard
ekyc_id_flutter: ^1.0.55 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.instance.setURL("http://ocr.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>();

    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();
    }

    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,
          ),
          ScannableDocument(
            mainSide: ObjectDetectionObjectType.PASSPORT_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: Center(
      //   child: TextButton(
      //     onPressed: () async {
      //       // final ImagePicker picker = ImagePicker();

      //       // final XFile? image =
      //       //     await picker.pickImage(source: ImageSource.gallery);
      //       // var bytes = await image?.readAsBytes();

      //       // if (bytes != null) {
      //       //   await documentDetector.setWhiteList([
      //       //     ObjectDetectionObjectType.NATIONAL_ID_0,
      //       //   ]);
      //       //   List<DocumentScannerResult> detections =
      //       //       await documentDetector.detect(bytes);

      //       //   if (detections.isNotEmpty) {
      //       //     showDialog(
      //       //       context: context,
      //       //       builder: (BuildContext context) {
      //       //         return Dialog(
      //       //           child: Image.memory(detections[0].documentImage),
      //       //         );
      //       //       },
      //       //     );
      //       //   }
      //       // }
      //       await showModalBottomSheet(
      //         context: context,
      //         isScrollControlled: true,
      //         builder: (BuildContext context) {
      //           return FaceScannerView(
      //             key: _faceScanner,
      //             options: FaceScannerOptions(
      //               useFrontCamera: true,
      //             ),
      //             onFaceScanned: onFaceScanned,
      //             overlayBuilder: (context, frameStatus, countdown) {
      //               return Column(
      //                 children: [
      //                   Text(frameStatus.toString()),
      //                   Text(countdown.toString()),
      //                 ],
      //               );
      //             },
      //           );

      //           // return LivenessDetectionView(
      //           //   options: LivenessDetectionOptions(
      //           //     language: Language.EN,
      //           //     prompts: [
      //           //       LivenessPromptType.LOOK_LEFT,
      //           //       LivenessPromptType.LOOK_RIGHT,
      //           //       LivenessPromptType.BLINKING,
      //           //     ],
      //           //   ),
      //           //   onLivenessTestCompleted: (LivenessDetectionResult r) async {
      //           //     print("Result: $r");
      //           //   },
      //           //   overlayBuilder: (
      //           //     context,
      //           //     frameStatus,
      //           //     countDown,
      //           //     progress,
      //           //     activePrompt,
      //           //     isFocusing,
      //           //   ) {
      //           //     return LivenessOverlayMinimal(
      //           //       options: LivenessDetectionOptions(
      //           //         language: Language.EN,
      //           //         prompts: [
      //           //           LivenessPromptType.LOOK_LEFT,
      //           //           LivenessPromptType.LOOK_RIGHT,
      //           //           LivenessPromptType.BLINKING,
      //           //         ],
      //           //       ),
      //           //       frameStatus: frameStatus,
      //           //       progress: progress,
      //           //       promptTimer: countDown,
      //           //       isFocusing: isFocusing,
      //           //       activePrompt: activePrompt,
      //           //     );
      //           //   },
      //           // );

      //           // return DocumentScannerView(
      //           //   onDocumentScanned: (mainSide, secondarySide) async {
      //           //     print(mainSide.toString());
      //           //     print(secondarySide?.toString());
      //           //   },
      //           //   options: DocumentScannerOptions(scannableDocuments: [
      //           //     ScannableDocument(
      //           //       mainSide: ObjectDetectionObjectType.NATIONAL_ID_0,
      //           //     )
      //           //   ]),
      //           //   overlayBuilder: (BuildContext context,
      //           //       FrameStatus frameStatus,
      //           //       DocumentSide side,
      //           //       int countDown) {
      //           //     return Container(
      //           //       child: Center(
      //           //           child: Text("$frameStatus, $side, $countDown")),
      //           //     );
      //           //   },
      //           // );
      //         },
      //       );
      //     },
      //     child: Text("Start KYC"),
      //   ),
      // ),
    );
  }
}
6
likes
0
points
854
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter Plugin to interact with EkycID.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, flutter, flutter_beep, flutter_font_icons, flutter_spinkit, http_parser, just_audio, vibration

More

Packages that depend on ekyc_id_flutter