autheo_sdk 1.0.8 copy "autheo_sdk: ^1.0.8" to clipboard
autheo_sdk: ^1.0.8 copied to clipboard

A Flutter SDK for KYC verification

example/lib/main.dart

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

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

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

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

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

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final firstNameController = TextEditingController();
  final lastNameController = TextEditingController();
  final phoneController = TextEditingController();
  final emailController = TextEditingController();

  bool _isAddressCheck = false;
  bool _isAmlCheck = false;
  bool _isCreditCheck = false;
  bool _isOtpRequired = false;

  @override
  void dispose() {
    firstNameController.dispose();
    lastNameController.dispose();
    phoneController.dispose();
    emailController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Autheo SDK Example'),
      ),
      body: SingleChildScrollView(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            TextField(
              controller: firstNameController,
              decoration: const InputDecoration(
                labelText: 'First name',
                border: OutlineInputBorder(),
              ),
            ),
            const SizedBox(height: 16),
            TextField(
              controller: lastNameController,
              decoration: const InputDecoration(
                labelText: 'Last name',
                border: OutlineInputBorder(),
              ),
            ),
            const SizedBox(height: 16),
            TextField(
              controller: phoneController,
              keyboardType: TextInputType.phone,
              decoration: const InputDecoration(
                labelText: 'Phone number',
                border: OutlineInputBorder(),
              ),
            ),
            const SizedBox(height: 16),
            TextField(
              controller: emailController,
              keyboardType: TextInputType.emailAddress,
              decoration: const InputDecoration(
                labelText: 'Email',
                border: OutlineInputBorder(),
              ),
            ),
            const SizedBox(height: 24),
            const Text(
              'Verification Options',
              style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
            ),
            const SizedBox(height: 8),
            SwitchListTile(
              title: const Text('Address Check'),
              value: _isAddressCheck,
              onChanged: (v) => setState(() => _isAddressCheck = v),
              contentPadding: EdgeInsets.zero,
            ),
            SwitchListTile(
              title: const Text('AML Check'),
              value: _isAmlCheck,
              onChanged: (v) => setState(() => _isAmlCheck = v),
              contentPadding: EdgeInsets.zero,
            ),
            SwitchListTile(
              title: const Text('Credit Check'),
              value: _isCreditCheck,
              onChanged: (v) => setState(() => _isCreditCheck = v),
              contentPadding: EdgeInsets.zero,
            ),
            SwitchListTile(
              title: const Text('OTP Required'),
              value: _isOtpRequired,
              onChanged: (v) => setState(() => _isOtpRequired = v),
              contentPadding: EdgeInsets.zero,
            ),
            const SizedBox(height: 24),
            SizedBox(
              width: double.infinity,
              child: ElevatedButton(
                onPressed: () async {
                  try {
                    final result = await AutheoSDK.startVerification(
                      context,
                      apiKey: 'your-api-key',
                      email: emailController.text,
                      phone: phoneController.text,
                      firstName: firstNameController.text,
                      lastName: lastNameController.text,
                      businessId: 'your-business-id',
                      verificationType: 'ID Verification',
                      addressCheckType: 'digital',
                      isAddressCheck: _isAddressCheck,
                      isAmlCheck: _isAmlCheck,
                      isCreditCheck: _isCreditCheck,
                      isOtpRequired: _isOtpRequired,
                    );

                    if (result.isSuccess) {
                      debugPrint('Verification passed ${result.data}');
                    } else {
                      debugPrint('Verification failed: ${result.message}');
                    }
                  } catch (e) {
                    if (!context.mounted) return;
                    ScaffoldMessenger.of(context).showSnackBar(
                      SnackBar(content: Text('Error: $e')),
                    );
                  }
                },
                child: const Text('Launch Verification'),
              ),
            ),
          ],
        ),
      ),
    );
  }
}