flutter_identity_comparison_sdk 1.0.1 copy "flutter_identity_comparison_sdk: ^1.0.1" to clipboard
flutter_identity_comparison_sdk: ^1.0.1 copied to clipboard

A Flutter SDK for identity comparison and liveness checks by Dikript Solutions.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Identity Comparison SDK Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: const HomePage(),
    );
  }
}

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

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  // Replace with your actual API key
  final String apiKey = 'live_key_8crtqlQ6F1TY5mYVivsOeJwLSWq2UYOaTCRbu9kwwp';
  final String apiUrl = 'https://api.dikript.com/dikript/api/v1/biometrics';
  
  // Result storage
  IdentityComparisonResult? _result;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Identity Comparison Demo'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            const SizedBox(height: 20),
            const Text(
              'Dikript Identity Comparison SDK Demo',
              style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
              textAlign: TextAlign.center,
            ),
            const SizedBox(height: 40),
            ElevatedButton(
              onPressed: _startIdentityVerification,
              style: ElevatedButton.styleFrom(
                padding: const EdgeInsets.symmetric(vertical: 16),
              ),
              child: const Text('Start Identity Verification', style: TextStyle(fontSize: 18)),
            ),
            const SizedBox(height: 40),
            if (_result != null) _buildResultCard(),
          ],
        ),
      ),
    );
  }

  Widget _buildResultCard() {
    final result = _result!;
    final isMatch = result.isMatch;
    
    return Card(
      elevation: 4,
      child: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              'Verification Result:',
              style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
            ),
            const SizedBox(height: 8),
            Row(
              children: [
                Text('Identity Match: ', style: TextStyle(fontSize: 16)),
                Text(
                  isMatch ? 'YES' : 'NO',
                  style: TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.bold,
                    color: isMatch ? Colors.green : Colors.red,
                  ),
                ),
              ],
            ),
            const SizedBox(height: 4),
            Text('Confidence: ${(result.confidence * 100).toStringAsFixed(2)}%', style: TextStyle(fontSize: 16)),
            if (result.message != null) ...[
              const SizedBox(height: 4),
              Text('Message: ${result.message}', style: TextStyle(fontSize: 16)),
            ],
            if (result.matchDetails != null) ...[
              const SizedBox(height: 8),
              Text('Face Match: ${result.matchDetails?.faceMatch == true ? 'YES' : 'NO'}', 
                   style: TextStyle(fontSize: 16)),
              Text('ID Match: ${result.matchDetails?.idMatch == true ? 'YES' : 'NO'}', 
                   style: TextStyle(fontSize: 16)),
            ],
          ],
        ),
      ),
    );
  }

  void _startIdentityVerification() async {
    final widget = IdentityComparisonWidget(
      apiKey: apiKey,
      apiUrl: apiUrl,
      appName: 'Demo App',
      onResult: (result) {
        setState(() {
          _result = result;
        });
        Navigator.of(context).pop();
      },
      onError: (error) {
        ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: Text('Error: $error')),
        );
        Navigator.of(context).pop();
      },
    );

    await showDialog(
      context: context,
      barrierDismissible: false,
      builder: (context) => Dialog(
        insetPadding: const EdgeInsets.all(0),
        child: Container(
          width: double.infinity,
          height: double.infinity,
          color: Colors.white,
          child: widget,
        ),
      ),
    );
  }
}
0
likes
130
points
71
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter SDK for identity comparison and liveness checks by Dikript Solutions.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

camera, flutter, google_mlkit_commons, google_mlkit_face_detection, http, path, path_provider, provider

More

Packages that depend on flutter_identity_comparison_sdk