NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
pub.dev
A comprehensive Flutter plugin for app security features including screen lock detection, background timeout, touch timeout and lifecycle monitoring. Supports chain calls and lock reason callbacks.
Last release 7 days ago
01 Oct 2026
Ships unpredictably
gaps range from 8 days to 6 months
Nearly every release is documented
notes for 19 of 20 stable releases
2 versions withdrawn
withdrawn after publishing
1 years old
24 releases · first in 2025
One column per month.
fix(ios): restore Flutter root view to its original container after s…
fix(ios): restore Flutter root view to its original container after s…
rootViewController.view 被挪进 secure 输入框内部,关闭时只是插到了 window.layer 最底层,脱离了原来的 UITransitionView/UIDropShadowView;之后 present 的系统控制器(如 PHPickerViewController 相册选择器)布局错乱、点击全部落到背后的遮罩上,表现为点不动、滑不动。现在开启时记录原父视图、层级位置和 frame,关闭时原样放回。window.layer, detached from UITransitionView/UIDropShadowView, which broke later presented system controllers (e.g. PHPickerViewController) — touches landed on the dimming view behind them. The original superview, index and frame are now recorded and restored.Android: screenLock only fires once — stopAllTimers() unregisters the screen-off receiver
Android: screenLock only fires once — stopAllTimers() unregisters the screen-off receiver
迁移到 Flutter Built-in Kotlin
迁移到 Flutter Built-in Kotlin
android.builtInKotlin=false 时仍应用 KGP(org.jetbrains.kotlin.android)以兼容旧工程;AGP 9+ 开启内置 Kotlin 时不再 apply KGP。
kotlinOptions 改为通过 KotlinAndroidProjectExtension.compilerOptions 设置 JVM target,避免无 Kotlin 扩展时出现 Could not find method kotlin();Kotlin 升级到 2.1.0。
参考:https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin/for-plugin-authorsiOS:修复 Package.swift 里 target 的 path 指向包根目录之外,导致 flutter run/构建报错 target 'app_security_lock' in package 'app_security_lock-0.3.5' is outside the packa
Package.swift 里 target 的 path 指向包根目录之外,导致 flutter run/构建报错
target 'app_security_lock' in package 'app_security_lock-0.3.5' is outside the package root
(启用了 Swift Package Manager 的 Flutter 工程会直接构建失败)ios/app_security_lock/Sources/app_security_lock/,CocoaPods 的 podspec 和 SPM 的
Package.swift 现在共用同一份源码,不再各自维护一份Package.swift 里 library product 命名错误(沿用 Dart 包名 app_security_lock 下划线),导致构建报错
product 'app-security-lock' required by package 'fluttergeneratedpluginswiftpackage' ... not found in package 'app_security_lock'。
Flutter 生成的 FlutterGeneratedPluginSwiftPackage 按「下划线转短横线」的约定引用各插件的 product,
现在改成 app-security-lock(短横线)Nothing published for this version
iOS:修复从多任务清理应用时崩溃(deinit 中调用带 [weak self] 的截屏保护清理会触发 objc_fatal)
deinit 中调用带 [weak self] 的截屏保护清理会触发 objc_fatal)iOS 截屏:secure UITextField 静默保护,相册截图显示与录屏一致的暗色模糊 + warningMessage 占位(应用内不弹层)
UITextField 静默保护,相册截图显示与录屏一致的暗色模糊 + warningMessage 占位(应用内不弹层)warningMessage 遮罩FLAG_SECURE 同时拦截截屏与录屏修复了一些问题
修复了一些问题
. 修复 deinit 中的崩溃问题 问题原因: 在 deinit 中调用 setScreenRecordingProtectionEnabled(false) 会触发异步操作 showSecurityOverlay() 和 hideSecurityOverlay() 使用了 DispatchQue
. 修复 deinit 中的崩溃问题 问题原因: 在 deinit 中调用 setScreenRecordingProtectionEnabled(false) 会触发异步操作 showSecurityOverlay() 和 hideSecurityOverlay() 使用了 DispatchQueue.main.async { [weak self] } 对象正在释放时,weak 引用可能失效,导致崩溃 修复方案: 在 deinit 中直接同步清理资源,不再调用可能触发异步操作的方法 直接同步移除安全覆盖视图,不使用异步操作 直接移除观察者,避免调用其他方法 2. 优化异步操作 将 showSecurityOverlay() 和 hideSecurityOverlay() 拆分为同步和异步版本 添加 performShowSecurityOverlay() 和 performHideSecurityOverlay() 方法,确保在主线程执行 在正常使用时使用异步,在 deinit 中使用同步清理 3. 修复观察者重复注册问题 移除了 setupScreenRecordingProtection() 中重复的 willEnterForegroundNotification 观察者 在 onEnterForeground() 中检查录屏状态,避免重复注册 确保观察者的添加和移除成对出现
本版本修复了一个严重的稳定性问题:当用户手动从最近任务列表中清理应用时,系统会错误地提示应用已崩溃。
本版本修复了一个严重的稳定性问题:当用户手动从最近任务列表中清理应用时,系统会错误地提示应用已崩溃。
invokeMethod() 中添加双层异常捕获,防止 Flutter 引擎销毁后尝试通信导致的崩溃onActivityDestroyed() 中添加完整的定时器和监听器清理逻辑onDetachedFromEngine() 的资源清理流程,安全处理生命周期回调注销IllegalArgumentExceptionsafeInvokeMethod() 包装器,防止在插件销毁时调用已释放的方法通道deinit 方法,分别注销各个通知观察者避免竞态条件lifecycleChannel?.invokeMethod() 调用替换为安全调用为验证修复效果,请按以下步骤测试:
init() 时传入 debug: true,通过原生日志查看清理过程本版本新增了强大的屏幕录制防护功能,确保应用内容不被非法录屏。
本版本新增了强大的屏幕录制防护功能,确保应用内容不被非法录屏。
UIScreen.capturedDidChangeNotification)WindowManager.LayoutParams.FLAG_SECURE 标志禁止屏幕录制// 启用/禁用录屏防护,支持自定义警告文本
Future<AppSecurityLock> screenRecordingProtectionEnabled(
bool enabled, {
String? warningMessage,
})
// 启用录屏防护并显示自定义文本
await lock.screenRecordingProtectionEnabled(
true,
warningMessage: '检测到屏幕录制,该操作已被阻止',
);
// 禁用录屏防护
await lock.screenRecordingProtectionEnabled(false);
// 也可以使用链式调用
await lock.screenRecordingProtectionEnabled(
true,
warningMessage: '屏幕正在被录制',
);
本版本对 API 进行了全面重构,提供更简洁、更直观的使用方式。
本版本对 API 进行了全面重构,提供更简洁、更直观的使用方式。
onLock 回调现在包含 LockReason 参数,可以知道是什么导致了锁定LockReason.screenLock - 设备屏幕锁定LockReason.backgroundTimeout - 后台超时LockReason.touchTimeout - 触摸超时(无操作超时)LockReason.unknown - 未知原因| 旧 API | 新 API | 说明 |
|---|---|---|
setOnAppLockedCallback(callback) |
onLock((reason) => ...) |
支持链式调用,包含锁定原因 |
setOnAppUnlockedCallback(callback) |
onUnlock(callback) |
支持链式调用 |
setOnEnterForegroundCallback(callback) |
onForeground(callback) |
支持链式调用 |
setOnEnterBackgroundCallback(callback) |
onBackground(callback) |
支持链式调用 |
setLockEnabled(enabled) |
setLocked(enabled) / lock() / unlock() |
更语义化 |
setScreenLockEnabled(enabled) |
screenLockEnabled(enabled) |
支持链式调用 |
setBackgroundLockEnabled(enabled) |
backgroundLockEnabled(enabled) |
支持链式调用 |
setBackgroundTimeout(seconds) |
backgroundTimeout(seconds) |
支持链式调用 |
setTouchTimeoutEnabled(enabled) |
touchTimeoutEnabled(enabled) |
支持链式调用 |
setTouchTimeout(seconds) |
touchTimeout(seconds) |
支持链式调用 |
restartTouchTimer() |
resetTouchTimer() |
更语义化 |
// 新的链式调用方式
final lock = AppSecurityLock()
..onLock((reason) {
print('应用已锁定,原因: ${reason.name}');
// reason: screenLock / backgroundTimeout / touchTimeout / unknown
})
..onUnlock(() => print('请解锁应用'))
..onForeground(() => print('进入前台'))
..onBackground(() => print('进入后台'));
await lock.init(
isScreenLockEnabled: true,
isBackgroundLockEnabled: true,
backgroundTimeout: 30.0,
);
@Deprecated新增debug倒计时
新增debug倒计时
降级示例代码的SDK版本,删除测试文件
降级示例代码的SDK版本,删除测试文件
降级flutter 版本和dart版本要求,以适配老项目
降级flutter 版本和dart版本要求,以适配老项目
New Debug Field: Added debug parameter to control log output for better development experience
修复ios 构建错误
修复ios 构建错误
添加安卓缺失的括号
添加安卓缺失的括号
Improved Production Reliability: Fixed iOS screen lock detection not working in production builds
protectedData notificationsUIApplication.protectedDataWillBecomeUnavailableNotification and protectedDataDidBecomeAvailableNotification for accurate screen lock eventsprotectedData notification observers for reliable screen lock detectionscreenLocked() and screenUnlocked() callback methodsstartListen() method with protectedData notification observersNothing published for this version
New Touch Timeout Functionality: Added touch event monitoring with configurable timeout lock
setTouchTimeoutEnabled(bool enabled) - Enable/disable touch timeout functionalitysetTouchTimeout(double timeoutSeconds) - Configure touch timeout durationrestartTouchTimer() - Manual restart of touch timeout timerinit() methodAdded Swift Package Manager Support: Package now supports iOS Swift Package Manager
ios/app_security_lock/Package.swift for complete pub.dev compatibilityPackage.swift file for Swift Package Manager supportEnhanced Documentation: Improved README with better usage examples and API documentation
Screen Lock Detection: Monitor when device screen is locked/unlocked
Your coding agent can read these notes before it upgrades. Set up the MCP server →