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

A Flutter plugin that provides native eKYC functionality for Android and iOS. Features include face liveness detection, camera flash support, and document verification with seamless integration into F [...]

example/lib/main.dart

// main.dart
import 'package:ekyc_plugin_example/face_authentications.dart';
import 'package:flutter/material.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      routes: {
        '/': (context) => const HomePage(),
      },
      onGenerateRoute: (settings) {
        if (settings.name == '/face_authentications') {
          final args = settings.arguments as Map<String, dynamic>?;
          final userId = args?['userId'] as String?;
          return MaterialPageRoute(
            builder: (_) => FaceAuthentications(userId: userId ?? ''),
          );
        }
        return null;
      },
      initialRoute: '/',
    );
  }
}

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

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

class _HomePageState extends State<HomePage> {
  final TextEditingController _controller = TextEditingController();

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  void _navigateToFaceAuth() async {
    // Unfocus keyboard first
    FocusScope.of(context).unfocus();

    final userId = _controller.text.trim();
    if (userId.isEmpty) {
      ScaffoldMessenger.of(context).showSnackBar(
        const SnackBar(
          content: Text('Please enter a user ID'),
        ),
      );
      return;
    }

    // Navigate và chờ quay lại
    await Navigator.of(context).pushNamed(
      '/face_authentications',
      arguments: {'userId': userId},
    );

    // Unfocus khi quay lại từ màn FaceAuthentications
    if (mounted) {
      FocusScope.of(context).unfocus();
    }
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      // Dismiss keyboard when tapping outside TextField
      onTap: () => FocusScope.of(context).unfocus(),
      child: Scaffold(
        body: SizedBox(
          width: MediaQuery.of(context).size.width,
          child: Column(
            mainAxisSize: MainAxisSize.max,
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              FractionallySizedBox(
                widthFactor: 0.55,
                child: TextField(
                  controller: _controller,
                  textInputAction: TextInputAction.done,
                  onSubmitted: (_) => _navigateToFaceAuth(),
                  decoration: const InputDecoration(
                    border: OutlineInputBorder(),
                    labelText: 'Enter User ID',
                    hintText: 'example: son',
                  ),
                ),
              ),
              const SizedBox(height: 24),
              ElevatedButton(
                onPressed: _navigateToFaceAuth,
                child: const Text('Go to Face authentication screen'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
0
points
210
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin that provides native eKYC functionality for Android and iOS. Features include face liveness detection, camera flash support, and document verification with seamless integration into Flutter apps.

Repository (GitHub)
View/report issues

Topics

#ekyc #kyc #face-detection #liveness-detection #biometric

Documentation

Documentation

License

unknown (license)

Dependencies

bridge_native, flutter, plugin_platform_interface

More

Packages that depend on ekyc_plugin

Packages that implement ekyc_plugin