1
0
mirror of https://github.com/nisrulz/flutter-examples.git synced 2026-08-25 17:24:01 +00:00
Files
flutter-examples/biometrics/lib/example.dart
Nishant Srivastava 6e3ff94bfe refactor: split app wrapper from focused example code (multi-file apps)
Convert 17 multi-file apps to the validated pattern: lib/main.dart keeps
only the MaterialApp bootstrap; a new lib/example.dart holds the full entry
screen and focused example code, importing existing supporting files
(screens/, tabs/, services/, models/, widgets/, utils/).

Apps: analytics_integration, animation_example, biometrics, bottom_sheet,
custom_home_drawer, google_signin, grid_layout, handling_routes,
image_editor, scan_qr_code, statless_counter_app, using_bottom_nav_bar,
using_custom_fonts, using_listview, using_listwheelscrollview,
using_platform_adaptive, view_pdf_file
2026-08-18 00:48:50 +02:00

89 lines
2.7 KiB
Dart

// Example: Biometric verification screen
import 'package:biometrics/biometrics_verifier.dart';
import 'package:flutter/material.dart';
class Example extends StatefulWidget {
const Example({super.key});
@override
State<Example> createState() => _ExampleState();
}
class _ExampleState extends State<Example> {
late bool isVerified;
late BiometricsVerifier verifier;
@override
void initState() {
super.initState();
isVerified = false;
verifier = BiometricsVerifier();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: SizedBox(
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
isVerified ? 'Verification Complete' : 'Unverified',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
isVerified
? TextButton(
onPressed: () {
setState(() {
isVerified = false;
});
},
child: const Text('Unverify'),
)
: TextButton(
onPressed: () async {
try {
await verifier
.verifyBiometrics('Please enter your fingerprint');
// ---- Add your logic after finger print verification here
// ---
// ---
setState(() {
isVerified = true;
});
} catch (e) {
// ---- Verification Failed
if (!context.mounted) return;
showDialog(
context: context,
builder: (c) => AlertDialog(
title: const Text('Error !'),
content: Text(e.toString()),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text('Ok'),
)
],
),
);
}
},
child: const Text('Verify with Fingerprint'),
),
],
),
),
);
}
}