Feature Request: Add Custom Duration for Keeping the Screen Awake

オープン
#153 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
66/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
dart, flutter
領域
mobile

調査の方向性

Start by reading the implementation of WakelockPlus.enable() and its platform interfaces to see how wake lock requests are handled across Android, iOS, macOS, Windows, Linux, and web. Check the existing tests for enable and disable behavior, then trace how a duration could be applied consistently. Done means an optional duration automatically disables the wake lock, while manual disable and indefinite enable continue to work.

索引モデルが issue の本文から書いたものです。

説明

It would be useful to support a custom duration when enabling the wake lock.

Currently, wakelock_plus allows keeping the screen awake indefinitely until WakelockPlus.disable() is called. However, there are use cases where developers only need to keep the screen on for a specific period.

I suggest introducing an optional duration parameter that automatically disables the wake lock after the specified time.

Proposed API

// Keep screen awake for 1 minute.
WakelockPlus.enable(
duration: const Duration(minutes: 1),
);

// Keep screen awake for 2 minutes.
WakelockPlus.enable(
duration: const Duration(minutes: 2),
);

// Keep screen awake indefinitely (current behavior).
WakelockPlus.enable();

Expected Behavior

Accept an optional Duration parameter when enabling the wake lock.

Automatically disable the wake lock when the specified duration expires.

If no duration is provided, preserve the current behavior (keep the screen awake until manually disabled).

Calling disable() manually should still work before the duration expires.

Use Case

For example, in reading or memorization applications, developers may want to prevent the screen from turning off while the user is actively reading, but only for a limited period (e.g., 1 or 2 minutes), without implementing their own timer and manually managing the wake lock lifecycle.

This would make the package more flexible and reduce the need for additional timer logic in applications.

主要言語
Dart
スター
110
フォーク
100
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fluttercommunity/wakelock_plus のほかの issue

fluttercommunity/wakelock_plus の issue をすべて見る

似ている issue

Dart の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。