Skip to content

Skaletek KYC Flutter SDK - Integration Guide

Overview

This guide walks you through integrating the Skaletek Flutter KYC SDK into your Flutter application

Installation

Add to your pubspec.yaml:

dependencies:
  skaletek_kyc_flutter: ^1.0.0

Platform Setup

Android (android/app/build.gradle)

android {
    compileSdkVersion 34
    defaultConfig {
        minSdkVersion 21
    }
}

iOS (ios/Runner/Info.plist)

<key>NSCameraUsageDescription</key>
<string>Camera access needed for ID verification</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Photo access needed to select ID documents</string>

Quick Start

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

class VerificationScreen extends StatelessWidget {
  void _startVerification() async {
    final result = await SkaletekKYC.instance.startVerification(
      token: "your_auth_token_here",
      userInfo: {
        "first_name": "John",
        "last_name": "Doe",
        "document_type": "PASSPORT",
        "issuing_country": "USA"
      },
      customization: {
        "doc_src": "LIVE", // or "FILE"
        "logo_url": "https://yourcompany.com/logo.svg",
        "logo_width": "250px",
        "logo_height": "70px", 
        "partner_name": "Your Company",
        "partner_phone": "1234567890",
        "partner_email": "support@yourcompany.com",
        "help_url": "https://yourcompany.com/help",
        "primary_color": "#1261C1"
      },
      onComplete: (success, data) {
        if (success) {
          print('Verification successful!');
          // Handle success - navigate to next screen, show success message, etc.
        } else {
          print('Verification failed: ${data['error']}');
          // Handle failure - show error message, retry option, etc.
        }
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ElevatedButton(
          onPressed: _startVerification,
          child: Text('Start Verification'),
        ),
      ),
    );
  }
}

Complete Example

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

class KYCScreen extends StatefulWidget {
  @override
  _KYCScreenState createState() => _KYCScreenState();
}

class _KYCScreenState extends State<KYCScreen> {
  bool _isVerifying = false;
  String _status = '';

  void _startKYCVerification() async {
    setState(() {
      _isVerifying = true;
      _status = 'Starting verification...';
    });

    await KYCFlutterSDK.instance.startVerification(
      token: "your_auth_token_here",
      userInfo: {
        "first_name": "John",
        "last_name": "Doe",
        "document_type": "PASSPORT",
        "issuing_country": "USA"
      },
      customization: {
        "doc_src": "LIVE", // Use camera to capture document
        "logo_url": "https://yourcompany.com/logo.svg",
        "partner_name": "Your Company",
        "primary_color": "#1261C1"
      },
      onComplete: (success, data) {
        setState(() {
          _isVerifying = false;
        });

        if (success) {
          setState(() {
            _status = 'Verification completed successfully!';
          });
          // Navigate to success screen or update UI
          _showSuccessDialog();
        } else {
          setState(() {
            _status = 'Verification failed: ${data['error'] ?? 'Unknown error'}';
          });
          // Show error message or retry option
          _showErrorDialog(data['error'] ?? 'Unknown error');
        }
      },
    );
  }

  void _showSuccessDialog() {
    showDialog(
      context: context,
      builder: (context) => AlertDialog(
        title: Text('Success!'),
        content: Text('Your identity has been verified.'),
        actions: [
          TextButton(
            onPressed: () => Navigator.pop(context),
            child: Text('OK'),
          ),
        ],
      ),
    );
  }

  void _showErrorDialog(String error) {
    showDialog(
      context: context,
      builder: (context) => AlertDialog(
        title: Text('Verification Failed'),
        content: Text(error),
        actions: [
          TextButton(
            onPressed: () => Navigator.pop(context),
            child: Text('OK'), 
          ),
          TextButton(
            onPressed: () {
              Navigator.pop(context);
              _startKYCVerification(); // Retry
            },
            child: Text('Retry'),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('KYC Verification')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            if (_isVerifying)
              CircularProgressIndicator()
            else
              ElevatedButton(
                onPressed: _startKYCVerification,
                child: Text('Start Identity Verification'),
              ),
            SizedBox(height: 20),
            Text(_status, textAlign: TextAlign.center),
          ],
        ),
      ),
    );
  }
}

Configuration Options

User Info (Required)

{
  "first_name": "John",
  "last_name": "Doe",
  "document_type": "PASSPORT", // PASSPORT, DRIVER_LICENSE, ID_CARD
  "issuing_country": "USA" // ISO country code
}

Customization Options

{
  "doc_src": "LIVE", // "LIVE" for camera, "FILE" for upload
  "logo_url": "https://yourcompany.com/logo.svg", // Optional
  "logo_width": "250px", // Optional
  "logo_height": "70px", // Optional
  "partner_name": "Your Company", // Optional
  "partner_phone": "1234567890", // Optional
  "partner_email": "support@yourcompany.com", // Optional
  "help_url": "https://yourcompany.com/help", // Optional
  "primary_color": "#1261C1" // Optional, hex color
}

Document Sources

Live Camera Capture

"doc_src": "LIVE" // SDK opens camera to capture ID document

File Upload

"doc_src": "FILE" // User selects existing photo from gallery

Handling Results

The onComplete callback provides the verification result:

onComplete: (bool success, Map<String, dynamic> data) {
  if (success) {
    // Verification completed successfully
    // data contains verification details
    print('Verification ID: ${data['verification_id']}');
    print('Status: ${data['status']}');
  } else {
    // Verification failed
    // data contains error information
    print('Error: ${data['error']}');
    print('Error Code: ${data['error_code']}');
  }
}

Common Error Handling

onComplete: (success, data) {
  if (!success) {
    String error = data['error'] ?? 'Unknown error';

    if (error.contains('camera')) {
      // Handle camera permission issues
      _showCameraPermissionDialog();
    } else if (error.contains('network')) {
      // No internet connection
      _showNetworkErrorDialog();
    } else if (error.contains('document')) {
      // Document not clear or invalid
      _showDocumentErrorDialog();
    } else if (error.contains('face')) {
      // Face liveness failed
      _showFaceVerificationErrorDialog();
    } else {
      // Generic error
      _showGenericErrorDialog(error);
    }
  }
}

API Reference

KYCFlutterSDK.instance.startVerification()

Future<void> startVerification({
  required String token,
  required Map<String, String> userInfo,
  required Map<String, String> customization,
  required Function(bool success, Map<String, dynamic> data) onComplete,
})