flutter_meon_kyc 2.0.4
flutter_meon_kyc: ^2.0.4 copied to clipboard
A comprehensive Flutter package for handling Know Your Customer (KYC) processes with automatic permissions, IPV support, payment integration, and complete lifecycle management.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter_meon_kyc/flutter_meon_kyc.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Meon KYC Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
useMaterial3: true,
),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Meon KYC Example'),
centerTitle: true,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.verified_user,
size: 100,
color: Colors.blue,
),
const SizedBox(height: 24),
const Text(
'Meon KYC Integration',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 8),
const Text(
'Complete your verification process',
style: TextStyle(
fontSize: 16,
color: Colors.grey,
),
),
const SizedBox(height: 48),
ElevatedButton.icon(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const KYCScreen(),
),
);
},
icon: const Icon(Icons.assignment_turned_in),
label: const Text('Start Individual KYC'),
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(
horizontal: 32,
vertical: 16,
),
textStyle: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(height: 16),
OutlinedButton.icon(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const KYCScreen(workflow: 'business'),
),
);
},
icon: const Icon(Icons.business),
label: const Text('Start Business KYC'),
style: OutlinedButton.styleFrom(
padding: const EdgeInsets.symmetric(
horizontal: 32,
vertical: 16,
),
textStyle: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
],
),
),
);
}
}
class KYCScreen extends StatelessWidget {
final String workflow;
const KYCScreen({
super.key,
this.workflow = 'individual',
});
@override
Widget build(BuildContext context) {
return Scaffold(
body: MeonKYC(
// Required parameter - replace with your company name
companyName: 'demo-company',
// Workflow type - can be 'individual', 'business', etc.
workflow: workflow,
// Enable IPV (In-Person Verification) features
enableIPV: true,
// Enable payment link handling
enablePayments: true,
// Auto-request permissions when IPV step is detected
autoRequestPermissions: true,
// Permission control (can be controlled from frontend)
enableCameraPermission: true, // Request camera for IPV
enableMicrophonePermission: true, // Request microphone for IPV
enableLocationPermission: true, // Request location for IPV
// Show custom header with navigation controls
showHeader: true,
// Custom header title
headerTitle: 'Complete Your KYC',
// Base URL for KYC service (use your custom domain if needed)
baseURL: 'https://live.meon.co.in',
// Success callback - called when KYC is completed
onSuccess: (data) {
debugPrint('KYC Success: $data');
// Show success dialog
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => AlertDialog(
icon: const Icon(
Icons.check_circle,
color: Colors.green,
size: 64,
),
title: const Text('KYC Completed!'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('Status: ${data['status']}'),
const SizedBox(height: 8),
Text(
'Completed at: ${data['timestamp']}',
style: const TextStyle(fontSize: 12),
),
],
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop(); // Close dialog
Navigator.of(context).pop(); // Close KYC screen
},
child: const Text('Done'),
),
],
),
);
},
// Error callback - called when an error occurs
onError: (error) {
debugPrint('KYC Error: $error');
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Error: $error'),
backgroundColor: Colors.red,
action: SnackBarAction(
label: 'Dismiss',
textColor: Colors.white,
onPressed: () {},
),
),
);
},
// Close callback - called when user closes the KYC screen
onClose: () {
debugPrint('KYC Closed by user');
Navigator.of(context).pop();
},
// Optional: Custom styles
customStyles: {
'header': const BoxDecoration(
color: Colors.blue,
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 4,
offset: Offset(0, 2),
),
],
),
'headerTitle': const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white,
),
},
),
);
}
}