flutter_accurascan_finger 1.0.0
flutter_accurascan_finger: ^1.0.0 copied to clipboard
This package is for digital user verification system powered by Accura Scan.
example/lib/main.dart
import 'dart:convert';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_accurascan_finger/flutter_accurascan_finger.dart';
void main() {
runApp(FingerprintVerificationApp());
}
class FingerprintVerificationApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: FingerprintVerificationScreen(),
);
}
}
class FingerprintVerificationScreen extends StatefulWidget {
@override
_FingerprintVerificationScreenState createState() =>
_FingerprintVerificationScreenState();
}
class _FingerprintVerificationScreenState
extends State<FingerprintVerificationScreen> {
bool leftHand = false;
bool rightHand = false;
bool leftThumb = false;
bool rightThumb = false;
bool bothThumbs = false;
List<dynamic> enrollTemplate = [];
List<dynamic> verifyTemplate = [];
@override
void initState() {
super.initState();
getMetaData();
}
Future<void> getMetaData() async {
try {
await AccuraFinger.getMetaData().then((value) => print(value));
} on PlatformException {}
if (!mounted) return;
}
Future<void>startEnroll()async {
String handSelected = "left";
if (rightHand) {
handSelected = "right";
}
var config = [handSelected];
try {
await AccuraFinger.startFingerEnroll(config)
.then((value) =>
{
setState(() {
dynamic result = json.decode(value);
var tempDict = result["template_data"];
enrollTemplate = tempDict.values.toList();
print("RESULT:- $result");
})
}).onError((error, stackTrace) =>
{
setState(() {})
});
} on PlatformException {}
}
Future<void>startVerify()async {
String handSelected = "left";
if (rightHand) {
handSelected = "right";
}
var config = [handSelected];
try {
await AccuraFinger.startFingerVerify(config)
.then((value) =>
{
setState(() {
dynamic result = json.decode(value);
var tempDict = result["template_data"];
verifyTemplate = tempDict.values.toList();
print("RESULT:- $result");
getResult();
})
}).onError((error, stackTrace) =>
{
setState(() {})
});
} on PlatformException {}
}
Future<void>getResult()async {
var config = [enrollTemplate,verifyTemplate];
try {
await AccuraFinger.getResult(config)
.then((value) =>
{
setState(() {
dynamic result = json.decode(value);
print("RESULT:- $result");
})
}).onError((error, stackTrace) =>
{
setState(() {})
});
} on PlatformException {}
}
bool get isAnyOptionSelected =>
leftHand || rightHand ;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("FingerPrint Verification"),
centerTitle: true,
backgroundColor: Colors.blue,
),
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: 20),
Text(
"Select Type",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
SizedBox(height: 30),
// Left Hand & Right Hand
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_buildSwitch("Left Hand", leftHand, (value) {
setState(() {
leftHand = value;
});
}),
_buildSwitch("Right Hand", rightHand, (value) {
setState(() {
rightHand = value;
});
}),
],
),
SizedBox(height: 20),
// Enroll Button
ElevatedButton(
onPressed: isAnyOptionSelected
? () {
// Handle enrollment logic
print("Enroll tapped");
startEnroll();
}
: null,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey,
foregroundColor: Colors.white,
minimumSize: Size(double.infinity, 50),
),
child: Text("Enroll"),
),
SizedBox(height: 15),
// Verify Button
ElevatedButton(
onPressed: isAnyOptionSelected
? () {
// Handle verification logic
print("Verify tapped");
startVerify();
}
: null,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
minimumSize: Size(double.infinity, 50),
),
child: Text("Verify"),
),
],
),
),
);
}
Widget _buildSwitch(String title, bool value, Function(bool) onChanged) {
return Row(
children: [
Switch(
value: value,
onChanged: onChanged,
activeColor: Colors.green,
),
Text(title, style: TextStyle(fontSize: 16)),
],
);
}
}