import "package:flutter/foundation.dart"; import "package:local_auth/local_auth.dart"; import "package:shared_preferences/shared_preferences.dart"; /// 생체인증 잠금 설정/검증. class LockService { LockService._(); static final LockService instance = LockService._(); static const _key = "spin.bioLock"; final _auth = LocalAuthentication(); Future isEnabled() async { final p = await SharedPreferences.getInstance(); return p.getBool(_key) ?? false; } Future setEnabled(bool v) async { final p = await SharedPreferences.getInstance(); await p.setBool(_key, v); } Future canCheck() async { try { return await _auth.isDeviceSupported() && await _auth.canCheckBiometrics; } catch (_) { return false; } } Future authenticate() async { try { return await _auth.authenticate( localizedReason: "spin 잠금을 해제하려면 인증하세요", options: const AuthenticationOptions(stickyAuth: true, biometricOnly: false), ); } catch (e) { debugPrint("lock: auth 오류 $e"); return false; } } }