Flutter Screen Lock 是一个跨平台包,可在 Android、iOS 及其他支持的平台上实现屏幕锁定。它支持密码和生物识别认证(如 Face ID 或指纹),以保护应用界面。适用于需要增强安全性的应用,例如银行或私密数据访问,可与 Flutter 生态系统无缝集成。该包利用原生平台功能实现可靠的认证,确保在各种设备上提供一致的用户体验。
适合场景
安全应用访问
保护敏感数据
生物识别登录
密码保护
应用锁功能
注重隐私的应用程序
主要特点
跨平台支持
生物识别认证
密码备用
原生集成
简易设置
可自定义的用户界面
适合对象
需要高安全性的应用
金融或健康应用
私有数据存储
用户隐私工具
开发人员构建应用锁
使用建议
需要平台特定权限
某些平台的自定义功能有限
Web 支持可能有限制
取决于设备生物识别功能的可用性
不适用于非交互式屏幕
可能需要为网页进行额外配置
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
Flutter Screen Lock
This Flutter plugin provides an feature for screen lock.
Enter your passcode to unlock the screen.
You can also use biometric authentication as an option.
Landscape view
Features
By the length of the character count
You can change Cancel and Delete widget
Optimizes the UI for device size and orientation
You can disable cancellation
You can use biometrics (local_auth plugin)
Biometrics can be displayed on first launch
Unlocked callback
You can specify a mismatch event.
Limit the maximum number of retries
Keyboard input support for devices with physical keyboards
Number keys (0-9) and numpad input
Backspace key for deletion
Enter key for confirmation
Escape key for cancellation
Usage
You can easily lock the screen with the following code.
To unlock, enter correctString.
Simple
If you give the same input as correctString, it will automatically close the screen.
You can have users create a new passcode with confirmation
import'package:flutter_screen_lock/flutter_screen_lock.dart';
screenLockCreate(
context: context,
onConfirmed: (value) => print(value), // store new passcode somewhere here
);
Control the creation state
import'package:flutter_screen_lock/flutter_screen_lock.dart';
final inputController = InputController();
screenLockCreate(
context: context,
inputController: inputController,
);
// Somewhere else...
inputController.unsetConfirmed(); // reset first and confirm input
Change all callback names from didSomething to onSomething
Change screenLock with confirm: true to screenLockCreate
Change ScreenLock with confirm: true to ScreenLock.create
Replace StyledInputConfig with KeyPadButtonConfig
Replace spacingRatio with fixed value spacing in Secrets
6.x to 7 migration
Requires dart >= 2.17 and Flutter 3.0
Replace InputButtonConfig with KeyPadConfig.
Change delayChild to delayBuilder. delayBuilder is no longer displayed in a new screen. Instead, it is now located above the Secrets.
Accept BuildContext in secretsBuilder.
5.x to 6 migration
ScreenLock does not use Navigator.pop internally anymore.
The developer should now pop by themselves when desired. screenLock call will pop automatically if onUnlocked is null.