ekyc_flutter_sdk 1.0.0 copy "ekyc_flutter_sdk: ^1.0.0" to clipboard
ekyc_flutter_sdk: ^1.0.0 copied to clipboard

retracted

A comprehensive Flutter SDK for eKYC (electronic Know Your Customer) identity verification. Supports NFC scanning of Japanese driver's licenses, My Number cards, and residence cards with face liveness [...]

example/example.dart

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

/// Complete example demonstrating the eKYC Flutter SDK
///
/// This example shows how to:
/// - Initialize the SDK with your API key
/// - Scan driver's licenses, My Number cards, and residence cards
/// - Perform face liveness checks
/// - Handle authentication and responses
///
/// For more examples, see: https://pub.dev/packages/ekyc_flutter_sdk

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'eKYC SDK Example',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const EkycExample(),
    );
  }
}

class EkycExample extends StatefulWidget {
  const EkycExample({super.key});

  @override
  State<EkycExample> createState() => _EkycExampleState();
}

class _EkycExampleState extends State<EkycExample> {
  // STEP 1: Initialize SDK with your API key
  late final KycApiClient _kycClient;

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

    // Initialize SDK with your API key
    _kycClient = KycApiClient(
      apiKey: 'YOUR_API_KEY_HERE', // Replace with your actual API key
    );
  }

  // STEP 2: Get authentication token from your backend
  Future<String> getAuthToken() async {
    // TODO: Implement your backend token retrieval
    // This should call your server to get a valid JWT token
    throw UnimplementedError(
      'Please implement getAuthToken() to retrieve tokens from your backend',
    );
  }

  // EXAMPLE 1: Scan Driver's License
  Future<void> scanDriverLicense() async {
    try {
      final String token = await getAuthToken();

      // Create KYC request
      final Map<String, dynamic> kycRequest = await _kycClient.createKycRequest(
        token: token,
      );
      final String requestId = kycRequest['id'].toString();

      // Scan the card
      final Map<String, dynamic> result = await _kycClient.scanDriverLicense(
        pin1: '1234', // First PIN (4 digits)
        pin2: '5678', // Second PIN (4 digits)
        token: token,
        tKycRequestId: requestId,
      );

      // Handle the result
      if (mounted) {
        ScaffoldMessenger.of(
          context,
        ).showSnackBar(SnackBar(content: Text('Success: ${result['name']}')));
      }
      print('Driver License scanned successfully: $result');
    } catch (e) {
      print('Error: $e');
    }
  }

  // EXAMPLE 2: Scan My Number Card
  Future<void> scanMyNumberCard() async {
    try {
      final String token = await getAuthToken();

      final Map<String, dynamic> kycRequest = await _kycClient.createKycRequest(
        token: token,
      );
      final String requestId = kycRequest['id'].toString();

      final Map<String, dynamic> result = await _kycClient.scanMyNumberCard(
        pin: '12345678901234', // 14-digit verification number B
        token: token,
        tKycRequestId: requestId,
      );

      if (mounted) {
        ScaffoldMessenger.of(
          context,
        ).showSnackBar(SnackBar(content: Text('Success: ${result['name']}')));
      }
      print('My Number Card scanned successfully: $result');
    } catch (e) {
      if (mounted) {
        ScaffoldMessenger.of(
          context,
        ).showSnackBar(SnackBar(content: Text('Error: $e')));
      }
      print('Error: $e');
    }
  }

  // EXAMPLE 3: Scan Residence Card with Face Verification
  Future<void> scanResidenceCard(BuildContext context) async {
    try {
      final String token = await getAuthToken();

      final Map<String, dynamic> kycRequest = await _kycClient.createKycRequest(
        token: token,
      );
      final String requestId = kycRequest['id'].toString();

      await _kycClient.scanResidenceCard(
        residenceNumber: 'AB1234567890', // 12-character residence number
        token: token,
        tKycRequestId: requestId,
      );

      if (mounted) {
        ScaffoldMessenger.of(context).showSnackBar(
          const SnackBar(content: Text('Residence Card scanned successfully')),
        );
      }

      // Optional: Perform face liveness check
      final Widget faceLiveness = await _kycClient.faceLivenessCheck(
        token: token,
        tKycRequestId: requestId,
        onMessageReceived: (String message) => print('Liveness: $message'),
        context: context,
      );

      // Show liveness UI to user
      if (context.mounted) {
        await Navigator.push(
          context,
          MaterialPageRoute(
            builder:
                (_) => Scaffold(
                  appBar: AppBar(title: const Text('Face Verification')),
                  body: faceLiveness,
                ),
          ),
        );
      }
    } catch (e) {
      if (mounted) {
        ScaffoldMessenger.of(
          context,
        ).showSnackBar(SnackBar(content: Text('Error: $e')));
      }
      print('Error: $e');
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('eKYC SDK Example')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: scanDriverLicense,
              child: const Text('Scan Driver\'s License'),
            ),
            const SizedBox(height: 16),
            ElevatedButton(
              onPressed: scanMyNumberCard,
              child: const Text('Scan My Number Card'),
            ),
            const SizedBox(height: 16),
            ElevatedButton(
              onPressed: () => scanResidenceCard(context),
              child: const Text('Scan Residence Card'),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
0
points
33
downloads

Publisher

unverified uploader

Weekly Downloads

A comprehensive Flutter SDK for eKYC (electronic Know Your Customer) identity verification. Supports NFC scanning of Japanese driver's licenses, My Number cards, and residence cards with face liveness detection.

License

unknown (license)

Dependencies

aws_common, aws_signature_v4, device_info_plus, flutter, flutter_inappwebview, http, image, package_info_plus, permission_handler

More

Packages that depend on ekyc_flutter_sdk

Packages that implement ekyc_flutter_sdk