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


RequirementsVersion/Details
Flutter SDK3.0.0 or higher
Dart2.17+
iOS12.0+
AndroidAPI Level 21 +
compileSdkVersion33

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

ParameterTypeRequiredDescription
contextBuildcContextYesFlutter build context
merchantkeystringYesMerchant public key
firstNamestringYesUser's first name
lastNamestringYesUser's last name
emailstringYesUser's email address
userRefstringYesUnique user reference (15 -20 chars)
configstringYesWidget configuration ID
onCancelFunctionYesCallback when cancelled
onVerifiedFunctionYesCallback when verified
onErrorFunctionYesCallback on error