パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v7.0.0

keep_screen_on

このプラグインは、画面の自動オフを無効にし、画面がオフにならないようにします。

AndroidiOS
30日間ダウンロード
3万
いいね数
54
Pub ポイント
160

パッケージをインストール

flutter pub add keep_screen_on

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

keep_screen_on パッケージは、デバイスの画面が自動的にオフにならないようにし、継続的な表示の可視性を確保します。動画プレーヤー、ナビゲーションアプリ、キオスクモードなど、画面の活動を途切れなく必要とするアプリに最適です。Android および iOS に対応しており、簡単な追加コマンドで Flutter プロジェクトにシームレスに統合できます。このプラグインは、デバイス上でウェイクロックを保持することで動作し、画面の明るさと活動状態を維持します。軽量で、複雑な設定なしに簡単に実装できるよう設計されています。

用途

  • 動画再生
  • ナビゲーションアプリ
  • キオスクモード
  • プレゼンテーションツール
  • 長時間実行されるタスク

主な機能

  • 自動的な画面の明るさ低下を防ぐ
  • クロスプラットフォーム(Android & iOS)
  • シンプルな統合
  • 最小構成
  • ウェイクロックの管理

適している対象

  • メディアアプリケーション
  • インタラクティブディスプレイ
  • 現場サービスツール
  • デジタルサイネージ
  • 時間に敏感なワークフロー

注意事項

  • バッテリー消費の増加
  • 一部のデバイスではユーザーの許可が必要です
  • バックグラウンド操作には適していません
  • システムの電力節約機能と競合する可能性があります
  • 画面の明るさに対する制御が限定的

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

KeepScreenOn

This plugin disables automatic screen off and prevents the screen from turning off.

Getting Started

Add this to your package's pubspec.yaml file:

dependencies:
  keep_screen_on: ^6.0.0

Usage

Import KeepScreenOn.

import 'package:keep_screen_on/keep_screen_on.dart';

To keep the screen from turning off, call the turnOn method of the KeepScreenOn class.

// Keep the screen on.
KeepScreenOn.turnOn();

Calling the turnOff method of the KeepScreenOn class will restore the screen to turn off automatically.
Alternatively, you can do the same by specifying false as the argument to the turnOn method.

// Reset
KeepScreenOn.turnOff();

// or...
KeepScreenOn.turnOn(on: false);

You can check if the screen is not turned off by checking the isOn property or isOff property.
Since isOn and isOff return Future <bool?>, you need to use "await" or receive the value with the "then" method.

Future<bool?> getScreenKeepOn() async {
  return await KeepScreenOn.isOn; 
}

Future<bool?> getScreenKeepOff() async {
  return await KeepScreenOn.isOff;
}
Android only.

The following functions are available on Android. Nothing happens even if you run it on an OS other than Android.

You can specify the withAllowLockWhileScreenOn argument to the turnOn and turnOff methods.
When withAllowLockWhileScreenOn: true is specified, FLAG_ALLOW_LOCK_WHILE_SCREEN_ON is also specified in addition to FLAG_KEEP_SCREEN_ON.

KeepScreenOn.turnOn(withAllowLockWhileScreenOn: true);

KeepScreenOn.turnOff(withAllowLockWhileScreenOn: true);

If you want to switch only FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, you can do so by calling the method below.

KeepScreenOn.addAllowLockWhileScreenOn();

KeepScreenOn.clearAllowLockWhileScreenOn();

You can check the assignment status of FLAG_ALLOW_LOCK_WHILE_SCREEN_ON from the isAllowLockWhileScreenOn property.

KeepScreenOn.isAllowLockWhileScreenOn

Each call returns the following values on non-Android OS:

Method/Property Returns
addAllowLockWhileScreenOn false
clearAllowLockWhileScreenOn false
isAllowLockWhileScreenOn null

Attention

When you call the turnOn method with no arguments or with on: true,
Android sets android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON for the activity window as an internal action.
iOS sets UIApplication.shared.isIdleTimerDisabled to true.

For this reason, be sure to use the dispose method of StatefulWidget etc.

KeepScreenOn.turnOff();

Should be called. If you forget to call turnOff (or turnOn(on: false)), the screen will not turn off automatically while the app is running.

For Android, when the activity is switched, the automatic screen off will follow the activity to which it was switched.
For iOS, automatic screen off is restored when you move to the background.

カテゴリー

依存関係

依存関係一覧 1 件

  • keep_screen_on_platform_interface^3.0.0

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。