flutter_app_lock_pro 1.0.0
flutter_app_lock_pro: ^1.0.0 copied to clipboard
Pro app lock for Flutter. Lock specific screens, auto-lock timer, PIN/pattern/biometric, wrong-attempt protection, screenshot protection, and background blur. Built for banking and fintech apps.
import 'package:flutter/material.dart';
import 'package:flutter_app_lock_pro/flutter_app_lock_pro.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await AppLock.enable(
const AppLockConfig(
pin: '1234',
autoLockAfter: Duration(minutes: 2),
maxAttempts: 5,
blockDuration: Duration(minutes: 5),
unlockMethods: [UnlockMethod.pin, UnlockMethod.biometric],
secureScreen: true,
backgroundBlur: true,
protectedRoutes: ['/wallet', '/profile', '/settings'],
),
);
runApp(const AppLockExampleApp());
}
class AppLockExampleApp extends StatelessWidget {
const AppLockExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'App Lock Pro Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.indigo),
useMaterial3: true,
),
initialRoute: '/',
onGenerateRoute: (settings) {
return MaterialPageRoute(
settings: settings,
builder: (context) => AppLockScope(
lockTitle: 'Unlock App',
biometricReason: 'Unlock to continue',
child: _buildPage(settings.name ?? '/'),
),
);
},
);
}
static Widget _buildPage(String route) {
switch (route) {
case '/wallet':
return const _PlaceholderPage(title: 'Wallet');
case '/profile':
return const _PlaceholderPage(title: 'Profile');
case '/settings':
return const _PlaceholderPage(title: 'Settings');
default:
return const HomePage();
}
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('App Lock Pro'),
),
body: ListView(
padding: const EdgeInsets.all(24),
children: [
const Text(
'Protected routes: /wallet, /profile, /settings. '
'PIN: 1234. Auto-lock after 2 min.',
style: TextStyle(fontSize: 14),
),
const SizedBox(height: 24),
ListTile(
title: const Text('Wallet'),
subtitle: const Text('Protected'),
leading: const Icon(Icons.account_balance_wallet),
onTap: () => Navigator.pushNamed(context, '/wallet'),
),
ListTile(
title: const Text('Profile'),
subtitle: const Text('Protected'),
leading: const Icon(Icons.person),
onTap: () => Navigator.pushNamed(context, '/profile'),
),
ListTile(
title: const Text('Settings'),
subtitle: const Text('Protected'),
leading: const Icon(Icons.settings),
onTap: () => Navigator.pushNamed(context, '/settings'),
),
const Divider(),
ListTile(
title: const Text('Lock now'),
leading: const Icon(Icons.lock),
onTap: () => AppLock.lockNow(),
),
],
),
);
}
}
class _PlaceholderPage extends StatelessWidget {
const _PlaceholderPage({required this.title});
final String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(title)),
body: Center(child: Text('$title (protected)')),
);
}
}