mantra_biometric_device 0.0.2 copy "mantra_biometric_device: ^0.0.2" to clipboard
mantra_biometric_device: ^0.0.2 copied to clipboard

A Flutter plugin to interact with Mantra biometric devices for UIDAI authentication.

example/lib/main.dart

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"),
          ],
        ),
      ),
    );
  }
}
0
likes
145
points
98
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to interact with Mantra biometric devices for UIDAI authentication.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

collection, flutter, flutter_web_plugins, plugin_platform_interface, web, xml

More

Packages that depend on mantra_biometric_device

Packages that implement mantra_biometric_device