hypersnapsdk_flutter 0.0.2 copy "hypersnapsdk_flutter: ^0.0.2" to clipboard
hypersnapsdk_flutter: ^0.0.2 copied to clipboard

outdated

Flutter Plugin for HyperSnap SDK

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:hypersnapsdk_flutter/hypersnapsdk_flutter.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String imagePath = "images/flutter-logo.png";

  @override
  void initState() {
    super.initState();
    initHyperSnapSDK();
  }

  /// Initialises the HyperSnapSDK
  void initHyperSnapSDK() async {
    // TODO: Add appId and appKey

    HyperSnapSDKFlutter.initialize(
        "", "", (await HyperSnapSDKFlutter.getValidParams())["RegionIndia"]);
  }

  /// Opens document capture screen
  void openDocumentCaptureScreen() async {
    Map docCaptureMap = await HyperSnapSDKFlutter.docsCaptureStart();
    Map docResultObj = docCaptureMap["resultObj"];
    Map docErrorObj = docCaptureMap["errorObj"];

    debugPrint("Results Map - " + docResultObj.toString());
    debugPrint("Error Map - " + docErrorObj.toString());

    if (docErrorObj.isNotEmpty) {
      // Handle error
      debugPrint(docErrorObj["errorMessage"]);
      debugPrint(docErrorObj["errorCode"]?.toString());
    } else {
      // Handle success results
      debugPrint(docResultObj["apiResult"]);
      debugPrint(docResultObj["imageUri"]);

      setState(() {
        imagePath = docResultObj["imageUri"];
      });
    }
  }

  /// Opens face capture screen
  void openFaceCaptureScreen() async {
    Map faceCaptureMap = await HyperSnapSDKFlutter.faceCaptureStart();
    Map faceResultObj = faceCaptureMap["resultObj"];
    Map faceErrorObj = faceCaptureMap["errorObj"];

    debugPrint("Results Map - " + faceResultObj.toString());
    debugPrint("Error Map - " + faceErrorObj.toString());

    if (faceErrorObj.isNotEmpty) {
      // Handle error
      debugPrint(faceErrorObj["errorMessage"]);
      debugPrint(faceErrorObj["errorCode"]?.toString());
    } else {
      // Handle success results
      debugPrint(faceResultObj["apiResult"]);
      debugPrint(faceResultObj["imageUri"]);

      setState(() {
        imagePath = faceResultObj["imageUri"];
      });
    }
  }

  /// Opens QR scanner screen
  void openQRScanner() async {
    Map map = await HyperSnapSDKFlutter.qrScanCaptureStart();
    debugPrint("QR Scan result - " + map.toString());
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
          appBar: AppBar(
            title: const Text('Plugin example app'),
          ),
          body: SingleChildScrollView(
            child: Center(
                child: Column(children: <Widget>[
                  Container(
                    margin: EdgeInsets.all(25),
                  ),
                  Container(
                    margin: EdgeInsets.all(25),
                    child: MaterialButton(
                      child: Text(
                        "Open Docs Capture",
                        style: TextStyle(fontSize: 20.0),
                      ),
                      color: Colors.blueAccent,
                      textColor: Colors.white,
                      onPressed: () async {
                        openDocumentCaptureScreen();
                      },
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.all(25),
                    child: MaterialButton(
                      child: Text(
                        "Open face Capture",
                        style: TextStyle(fontSize: 20.0),
                      ),
                      color: Colors.blueAccent,
                      textColor: Colors.white,
                      onPressed: () async {
                        openFaceCaptureScreen();
                      },
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.all(25),
                    child: MaterialButton(
                      child: Text(
                        "Open QR Scan Capture",
                        style: TextStyle(fontSize: 20.0),
                      ),
                      color: Colors.blueAccent,
                      textColor: Colors.white,
                      onPressed: () async {
                        openQRScanner();
                      },
                    ),
                  ),
                ])),
          ),
        ));
  }
}
13
likes
0
points
5.08k
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter Plugin for HyperSnap SDK

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on hypersnapsdk_flutter

Packages that implement hypersnapsdk_flutter