idflow_myid 1.0.4
idflow_myid: ^1.0.4 copied to clipboard
IDFlow SDK plugin for Flutter. Package supports iOS and Android to verify users identity.
example/lib/main.dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:idflow_myid/idflow_config.dart';
import 'package:idflow_myid/idflow_enums.dart';
import 'package:idflow_myid/idflow_myid.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String? _error;
IDFlowResult? _result;
// 1x1 transparent PNG, used only to demonstrate infoImageBase64 wiring.
static const _sampleInfoImageBase64 =
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=';
Future<void> init() async {
String? error;
IDFlowResult? result;
try {
final idflowResult = await IDFlowClient.start(
config: IDFlowConfig(
entryMode: IDFlowEntryMode.selfieOnly,
locale: IDFlowLocale.kyrgyz,
presentationStyle: IDFlowPresentationStyle.full,
documentConfig: const IDFlowDocumentConfig(timeoutSeconds: 180),
videoConfig: const IDFlowVideoConfig(
videoFilePath: '/data/local/tmp/idflow_video.mp4',
),
faceConfig: const IDFlowFaceConfig(useActiveLiveness: true),
activeLivenessConfig: const IDFlowActiveLivenessConfig(
uiVariant: IDFlowActiveLivenessUiVariant.variant1,
challengeTimeoutMs: 15000,
),
),
iosAppearance: const IDFlowIOSAppearance(
face: IDFlowIOSFaceAppearance(
infoImageBase64: _sampleInfoImageBase64,
),
),
);
error = null;
result = idflowResult;
} catch (e) {
error = e.toString();
result = null;
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_error = error;
_result = result;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('IDFlow Sample'),
),
body: Center(
child: Column(
children: [
MaterialButton(
onPressed: init,
child: const Text('Start SDK'),
),
Text(_result?.personalNumber ?? _error ?? 'Failure'),
Text(_result?.idSeriesNumber ?? _error ?? 'Failure'),
],
),
),
),
);
}
}