vcheck_flutter_test 1.0.1 copy "vcheck_flutter_test: ^1.0.1" to clipboard
vcheck_flutter_test: ^1.0.1 copied to clipboard

PlatformAndroidiOS
outdated

VCheck SDK for Flutter with dev/test environment

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:vcheck_flutter_test/vcheck_flutter.dart';
import 'package:vcheck_flutter_test_example/result_widget.dart';

//For test env only:
const String PARTNER_SECRET = "7zUzkI7ncfQgKT7Ktozk9OYfr8KJNb";
const int PARTNER_ID = 1;

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final navigatorKey = GlobalKey<NavigatorState>();

  @override
  void initState() {
    super.initState();
    debugPrint("INIT STATE");
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: navigatorKey,
      home: Scaffold(
        appBar: AppBar(
          title: const Text('VCheck Flutter demo'),
        ),
        body: Center(
          child: Padding(
            padding: const EdgeInsets.all(25.0),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: [
                const SizedBox(width: 0, height: 50),
                MaterialButton(
                    color: Colors.blue,
                    textColor: Colors.white,
                    onPressed: () {
                      startSDK(
                          verificationScheme:
                              VerificationSchemeType.FULL_CHECK);
                    },
                    child: const Text("Full scheme")),
                const SizedBox(width: 0, height: 20),
                MaterialButton(
                    color: Colors.blue,
                    textColor: Colors.white,
                    onPressed: () {
                      startSDK(
                          verificationScheme:
                              VerificationSchemeType.DOCUMENT_UPLOAD_ONLY);
                    },
                    child: const Text("Document upload")),
                const SizedBox(width: 0, height: 20),
                MaterialButton(
                    color: Colors.blue,
                    textColor: Colors.white,
                    onPressed: () {
                      startSDK(
                          verificationScheme:
                              VerificationSchemeType.LIVENESS_CHALLENGE_ONLY);
                    },
                    child: const Text("Face check"))
              ],
            ),
          ),
        ),
      ),
    );
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> startSDK(
      {VerificationSchemeType verificationScheme =
          VerificationSchemeType.FULL_CHECK}) async {
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      VCheckSDK.start(
          partnerId: PARTNER_ID,
          partnerSecret: PARTNER_SECRET,
          verifScheme: verificationScheme,
          languageCode: "en",
          partnerEndCallback: partnerEndCallback());
    } on PlatformException {
      debugPrint('Caught PlatformException!');
    }
    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;
  }

  Function partnerEndCallback() {
    return () {
      debugPrint("Triggered Dart callback for SDK finish");

      navigatorKey.currentState?.push<void>(
        MaterialPageRoute<void>(
          builder: (BuildContext context) => const ResultWidget(),
        ),
      );
    };
  }
}
0
likes
140
points
0
downloads

Publisher

unverified uploader

Weekly Downloads

VCheck SDK for Flutter with dev/test environment

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on vcheck_flutter_test

Packages that implement vcheck_flutter_test