faceki_blaze_sdk 1.0.2 copy "faceki_blaze_sdk: ^1.0.2" to clipboard
faceki_blaze_sdk: ^1.0.2 copied to clipboard

FACEKI Flutter EKYC SDK

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:faceki_blaze_sdk/faceki_ekyc.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomeScreen(),
    );
  }
}

class HomeScreen extends StatefulWidget {
  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  final TextEditingController verificationLinkController =
      TextEditingController(text: "EnterValueOfURL");
  final TextEditingController requestIdController = TextEditingController(text: "sample");

  Faceki_Blaze_SDK? cameraPackage;
  bool _isLoading = false; // Track the loading state

  Future<void> launchCamera() async {
    // Ensure the camera package is only initialized with non-empty values
    if (verificationLinkController.text.isNotEmpty) {
      setState(() {
        _isLoading = true; // Show loader
      });

      cameraPackage = Faceki_Blaze_SDK(
        verification_link: verificationLinkController.text,
        record_identifier: "",
        turnGuidanceOff: false,
        termsAndConditionUrl: 'https://faceki.com/privacy-policy/',
      );

      await cameraPackage!.launchEKYCFlow(context, (verificationResponse) {
        // Handle completion of the process
        print("overridedSelfie");
        // Navigator.of(context).popUntil((route) => route.isFirst);
      });

      setState(() {
        _isLoading = false; // Hide loader
      });
    } else {
      showDialog(
        context: context,
        builder: (ctx) => AlertDialog(
          title: Text('Error'),
          content: Text('Please enter all the details'),
          actions: <Widget>[
            TextButton(
              onPressed: () {
                Navigator.of(ctx).pop();
              },
              child: Text('OK'),
            ),
          ],
        ),
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('FACEKI DEMO APP'),
      ),
      body: Stack(
        children: [
          Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              children: <Widget>[
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: TextField(
                    controller: verificationLinkController,
                    decoration: InputDecoration(
                      labelText: 'Verification Link',
                      border: OutlineInputBorder(),
                    ),
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: TextField(
                    controller: requestIdController,
                    decoration: InputDecoration(
                      labelText: 'Request ID',
                      border: OutlineInputBorder(),
                    ),
                  ),
                ),
                ElevatedButton(
                  onPressed: launchCamera,
                  child: Text('Launch FACEKI SDK'),
                ),
              ],
            ),
          ),
          if (_isLoading)
            Center(
              child: CircularProgressIndicator(), // Show progress loader
            ),
        ],
      ),
    );
  }
}