Flutter SDK
The Flutter SDK provides a platform channel implementation supporting both iOS and Android with native Kotlin/Swift bridges.
Installation
Step 1: Add Dependency
Add to pubspec.yaml:
dependencies:
flutter:
sdk: flutter
flutter_identity_kyc: ^1.0.0
permission_handler: ^10.0.0
Step 2: Install
flutter pub get
Requirements
| Requirements | Version/Details | |
|---|---|---|
| Flutter SDK | 3.0.0 or higher | |
| Dart | 2.17+ | |
| iOS | 12.0+ | |
| Android | API Level 21 + | |
| compileSdkVersion | 33 |
Platform Configuration
Android Setup
AndroidManifest.xml - Add at android/app/src/main/AndroidManifest.xml:
android/build.gradle - Add:
allprojects {
ext {
compileSdkVersion = 33
targetSdkVersion = 33
minSdkVersion = 21
}
repositories {
google()
mavenCentral()
}
}
subprojects {
afterEvaluate { project ->
if (project.hasProperty('android')) {
project.android {
if (namespace == null) {
namespace project.group
}
}
}
}
}
iOS Setup
Info.plist - Add to ios/Runner/Info.plist:
NSPhotoLibraryUsageDescription
App needs access to photo library for profile images
NSCameraUsageDescription
To capture profile photo please grant camera access
NSMicrophoneUsageDescription
To record audio for verification
5.2.5 Basic Implementation
import 'package:flutter/material.dart';
import 'package:flutter_identity_kyc/flutter_identity_kyc.dart';
import 'package:permission_handler/permission_handler.dart';
void main() {
runApp(MaterialApp(home: MyApp()));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State {
@override
void initState() {
super.initState();
requestPermissions();
}
Future requestPermissions() async {
await Permission.camera.request();
await Permission.microphone.request();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Identity Verification'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
FlutterIdentityKyc.showWidget(
InputParameters(
context: context,
merchantKey: "your-merchant-key",
firstName: "John",
lastName: "Doe",
email: "[email protected]",
userRef: "unique-user-ref",
config: "your-config-id",
onCancel: (response) {
print('Verification cancelled: $response');
},
onVerified: (response) {
print('Verification successful: $response');
},
onError: (error) {
print('Verification error: $error');
}
)
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Color(0xFF0D2525),
padding: EdgeInsets.symmetric(horizontal: 30, vertical: 15),
),
child: Text(
'Verify My Identity',
style: TextStyle(fontSize: 16, color: Colors.white),
),
),
),
);
}
}
Advanced Flutter Example
import 'package:flutter/material.dart';
import 'package:flutter_identity_kyc/flutter_identity_kyc.dart';
class VerificationScreen extends StatelessWidget {
final String userId;
final Function(Map<String, dynamic>) onSuccess;
VerificationScreen({
required this.userId,
required this.onSuccess,
});
void startVerification(BuildContext context) {
FlutterIdentityKyc.showWidget(
InputParameters(
context: context,
merchantKey: "your-merchant-key",
firstName: "John",
lastName: "Doe",
email: "[email protected]",
userRef: userId,
config: "your-config-id",
onCancel: (response) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Verification cancelled')),
);
},
onVerified: (response) {
onSuccess(response);
Navigator.pop(context);
},
onError: (error) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Verification Error'),
content: Text(error.toString()),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text('OK'),
),
],
),
);
},
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Verification')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.verified_user, size: 80, color: Color(0xFF0D2525)),
SizedBox(height: 20),
Text(
'Identity Verification Required',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
SizedBox(height: 40),
ElevatedButton(
onPressed: () => startVerification(context),
child: Text('Start Verification'),
),
],
),
),
);
}
}
Input Parameters API
| Parameter | Type | Required | Description |
|---|---|---|---|
| context | BuildcContext | Yes | Flutter build context |
| merchantkey | string | Yes | Merchant public key |
| firstName | string | Yes | User's first name |
| lastName | string | Yes | User's last name |
| string | Yes | User's email address | |
| userRef | string | Yes | Unique user reference (15 -20 chars) |
| config | string | Yes | Widget configuration ID |
| onCancel | Function | Yes | Callback when cancelled |
| onVerified | Function | Yes | Callback when verified |
| onError | Function | Yes | Callback on error |
Updated about 5 hours ago
