mantra_biometric_device 0.0.2
mantra_biometric_device: ^0.0.2 copied to clipboard
A Flutter plugin to interact with Mantra biometric devices for UIDAI authentication.
import 'dart:developer';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:mantra_biometric_device/mantra_biometric.dart';
import 'package:mantra_biometric_device/mantra_biometric_device.dart';
import 'package:mantra_biometric_device/utils/mantra_plugin_exception.dart';
void main() {
runApp(MaterialApp(home: const MyApp()));
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _mantraBiometricPlugin = MantraBiometric();
@override
void initState() {
super.initState();
}
displyAlert(String message) {
showDialog(
context: context,
builder: (context) => AlertDialog(content: Text(message)),
);
}
String result = "";
getDeviceInfo() async {
try {
String output = await _mantraBiometricPlugin.getDeviceInformation() ?? "";
result = output;
setState(() {});
} on RDClientNotFound catch (e) {
displyAlert("Install Clinet");
} catch (e) {
displyAlert("Something Went Wrong $e");
}
}
scanFingerPrint() async {
try {
String wadh = "";
String pidOptions =
"<PidOptions ver=\"1.0\"> <Opts fCount=\"1\" fType=\"2\" pCount=\"0\" format=\"0\" pidVer=\"2.0\" wadh=\"$wadh\" timeout=\"20000\" posh=\"UNKNOWN\" env=\"P\" /> </PidOptions>";
result =
await _mantraBiometricPlugin.captureFingerPrint(
pidOptions: pidOptions,
) ??
"";
setState(() {});
} on RDClientNotFound catch (e) {
log("${e.code}");
displyAlert("Install Clinet");
} catch (e) {
displyAlert("Something Went Wrong $e");
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Mantra Biometric Example')),
body: SingleChildScrollView(
child: Column(
children: [
MaterialButton(
onPressed: getDeviceInfo,
child: const Text("Get Device Information"),
),
const SizedBox(height: 20),
MaterialButton(
onPressed: scanFingerPrint,
child: const Text("Scan Fingure Print"),
),
const SizedBox(height: 20),
Text("$result"),
],
),
),
);
}
}