idemia_l1rd_invoker 0.0.1
idemia_l1rd_invoker: ^0.0.1 copied to clipboard
A Flutter plugin for integrating IDEMIA L1 RD (Registered Device) biometric services for Aadhaar authentication in India.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:idemia_l1rd_invoker/idemia_l1rd_invoker.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 _platformVersion = 'Unknown';
final _idemiaL1rdInvokerPlugin = IdemiaL1rdInvoker();
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
platformVersion =
await _idemiaL1rdInvokerPlugin.getPlatformVersion() ??
'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// 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(() {
_platformVersion = platformVersion;
});
}
/// call L1RD
Future<void> _callRD() async {
// Implement the L1RD invocation logic here
try {
final result = await IdemiaL1rdInvoker.getDeviceInfo();
// Handle the result as needed
if (!mounted) return;
showAboutDialog(
context: context,
children: [Text('L1RD Result: $result')],
);
print('L1RD invocation result: $result');
} on PlatformException catch (e) {
showAboutDialog(
context: context,
children: [Text('L1RD Error: ${e.message}')],
);
}
}
/// capture fingerprint
Future<void> _captureFingerprint() async {
// Example PID options XML string
String pidOptions =
'<PidOptions ver="1.0"><Opts fCount="1" fType="0" format="0" pidVer="2.0" timeout="10000" otp="" wadh="" posh=""/></PidOptions>';
try {
final result = await IdemiaL1rdInvoker.captureFingerprint(pidOptions);
// Handle the result as needed
if (!mounted) return;
showAboutDialog(
context: context,
children: [Text('Fingerprint Capture Result: $result')],
);
print('Fingerprint capture result: $result');
} on PlatformException catch (e) {
showAboutDialog(
context: context,
children: [Text('Fingerprint Capture Error: ${e.message}')],
);
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('RD Service Flutter Plugin example app'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
DecoratedBox(
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(8),
),
child: Padding(
padding: EdgeInsets.symmetric(
vertical: 8.0,
horizontal: 16.0,
),
child: Text(
'Running on: $_platformVersion\n',
style: TextStyle(color: Colors.white, fontSize: 16),
textAlign: TextAlign.center,
),
),
),
SizedBox(height: 10),
ElevatedButton(onPressed: _callRD, child: Text('Invoke L1RD')),
ElevatedButton(
onPressed: _captureFingerprint,
child: Text('Capture Fingerprint'),
),
],
),
),
),
);
}
}