Feature Request: Add Custom Duration for Keeping the Screen Awake

Aperta
#153 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
66/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
dart, flutter
Ambito
mobile

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Dart
Stelle
110
Fork
100
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di fluttercommunity/wakelock_plus

Tutte le issue di fluttercommunity/wakelock_plus

Issue simili

Altre issue su Dart

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.