import 'package:local_auth/local_auth.dart'; import 'package:shared_preferences/shared_preferences.dart'; class BiometricService { static final _auth = LocalAuthentication(); static const _key = 'biometric_enabled'; static Future isAvailable() async { final canCheck = await _auth.canCheckBiometrics; final isSupported = await _auth.isDeviceSupported(); return canCheck && isSupported; } static Future isEnabled() async { final prefs = await SharedPreferences.getInstance(); return prefs.getBool(_key) ?? false; } static Future setEnabled(bool value) async { final prefs = await SharedPreferences.getInstance(); await prefs.setBool(_key, value); } static Future authenticate() async { try { return await _auth.authenticate( localizedReason: 'Confirm your identity to open Casha', options: const AuthenticationOptions( biometricOnly: false, stickyAuth: true, ), ); } catch (_) { return false; } } }