myaza_kyc_sdk_flutter 2.0.0 copy "myaza_kyc_sdk_flutter: ^2.0.0" to clipboard
myaza_kyc_sdk_flutter: ^2.0.0 copied to clipboard

Myaza KYC SDK — ID verification, liveness detection, and document OCR for Flutter

example/lib/main.dart

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

void main() => runApp(const ExampleApp());

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Myaza Identity Example',
      debugShowCheckedModeBanner: false,
      home: HomeScreen(),
    );
  }
}

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

  void _startVerification(BuildContext context) {
    // On-device liveness ships inside the SDK and is on by default — no setup
    // needed. The flow uploads media and submits, then returns immediately;
    // the verification result is delivered asynchronously via webhook.
    MyazaKYC.show(
      context: context,
      config: const MyazaKYCConfig(
        // The environment is derived from the key prefix — a `pk_test_*` key
        // targets staging automatically (no `environment` parameter).
        apiKey: 'pk_test_xxxxxxxxxxxxxxxxxxxxxxxx',
        country: Country.NG,
        idTypes: [IdType.bvn, IdType.nin, IdType.passport],
        enableSelfie: true,
        enableDocumentCapture: true,
        enableLiveness: true,
        appearance: MyazaKYCAppearance(
          companyName: 'Myaza',
          theme: MyazaThemeMode.light,
        ),
        metadata: {'userId': 'usr_123'},
      ),
      onSubmit: (KYCSubmission submission) {
        // Fires once the server accepts the submission. `status` is always
        // 'pending' here — the final outcome arrives later via webhook (or by
        // polling GET /api/kyc/status/:verificationId).
        debugPrint('Submitted: ${submission.verificationId}');
      },
      onError: (KYCError error) {
        // Technical errors only (network / invalid key / insufficient credits /
        // upload). Verification *failures* never come through here.
        debugPrint('Error (${error.code}): ${error.message}');
      },
      onClose: () => debugPrint('KYC closed'),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Myaza KYC Example')),
      body: Center(
        child: FilledButton(
          onPressed: () => _startVerification(context),
          child: const Text('Verify Identity'),
        ),
      ),
    );
  }
}