flutter_is_lock_screen
デバイスがロック画面にあるかどうかを検出する Flutter プラグイン。アプリがスクリーンのロックによってバックグラウンドに移行したのか、アプリから離れたのかを判断するのに役立ちます。
- スター
- 4
- フォーク
- 34
- 最終プッシュ(UTC)
- 2023/03/13
- プロジェクト状態
- 公開中
元の README
以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。
is_lock_screen
Detects if device is locked. Useful for determining whether app entered background due to locking screen or leaving app.
Usage
Import library and call the following method.
Note that this only works on physical device for iOS.
bool? result = await isLockScreen();
You will probably observe the AppLifecycleState with a WidgetsBindingObserver and call this when app is in background:
@override
void didChangeAppLifecycleState(AppLifecycleState state) async {
super.didChangeAppLifecycleState(state);
if (state == AppLifecycleState.inactive) {
print('app inactive, is lock screen: ${await isLockScreen()}');
} else if (state == AppLifecycleState.resumed) {
print('app resumed');
}
}
See example app code for details
Why this plugin?
An alternative to this plugin is hardware_buttons, which uses non-public API (com.apple.springboard.lockcomplete) on iOS to detect lock button usage and violates App Store requirements.
To circumvent this issue, this plugin detects whether iOS device is in lock screen by checking if screen brightness is 0.0 (the user-adjustable minimum is >0.01).
On android, this plugin uses KeyguardManager and PowerManager API to check if device is secured or display is off as suggested in this gist. A similar flow was tested on iOS with LocalAuthentication and UIApplication.shared.isProtectedDataAvailable but failed due to long grace period of the system lock down. The flag always return true the moment screen is locked.
カテゴリー
使用している依存関係
依存関係一覧 2 件
- flutter
{"sdk":"flutter"} - flutter_test開発用
{"sdk":"flutter"}
プロジェクトに合うリポジトリを選ぶには?
用途で絞り込み、開発状況を比較し、採用前に元のリポジトリで要件を確認しましょう。
- 名前・作者・説明で検索し、技術トピックで絞り込みます。
- スター、フォーク、最近のプッシュを比較します。スターは関心の目安であり、品質の保証ではありません。
- 利用前に GitHub で README、ライセンス、Issues を確認します。
情報源と管理
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗