搜尋分類、套件與程式碼儲存庫

GitHub 儲存庫elise-ng/flutter_is_lock_screen

flutter_is_lock_screen

用於檢測裝置是否處於鎖定畫面的 Flutter 外掛程式。對於判斷應用程式進入背景是因為鎖定畫面還是離開應用程式非常有用。

flutter_is_lock_screen 專案封面
星標
4
分支
34
最近推送(UTC)
2023年3月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.

Elise Ng GitHub avatar
GitHub 作者

Elise Ng ↗

Trying to make our world suck less.

ex-@oursky ex-@USThing Toronto
語言KotlinDartRubyHTMLSwiftObjective-C

分類

使用的依賴

依賴清單 2 項

  • flutter{"sdk":"flutter"}
  • flutter_test開發依賴{"sdk":"flutter"}

如何選擇適合專案的儲存庫?

先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。

  1. 透過儲存庫名稱、作者或描述搜尋,再依技術分類縮小範圍。
  2. 綜合星標、分支與最近推送比較專案;星標反映社群關注,不保證品質。
  3. 使用前在 GitHub 確認 README、授權條款與 Issues。

來源與維護

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗