mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2026-08-25 01:05:36 +00:00
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
This commit is contained in:
88
biometrics/lib/example.dart
Normal file
88
biometrics/lib/example.dart
Normal file
@@ -0,0 +1,88 @@
|
||||
// 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'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:biometrics/biometrics_verifier.dart';
|
||||
import 'package:biometrics/example.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(Biometrics());
|
||||
void main() => runApp(const Biometrics());
|
||||
|
||||
class Biometrics extends StatelessWidget {
|
||||
const Biometrics({super.key});
|
||||
@@ -13,92 +13,7 @@ class Biometrics extends StatelessWidget {
|
||||
theme: ThemeData(
|
||||
appBarTheme: const AppBarTheme(elevation: 0),
|
||||
),
|
||||
home: Home(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Home extends StatefulWidget {
|
||||
const Home({super.key});
|
||||
|
||||
@override
|
||||
State<Home> createState() => _HomeState();
|
||||
}
|
||||
|
||||
class _HomeState extends State<Home> {
|
||||
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'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
home: const Example(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user