Feature Request: Add Custom Duration for Keeping the Screen Awake
还没有人认领这个 Issue。
评估
调研方向
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
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
fluttercommunity/wakelock_plus 的其他 Issue
-
Web: TypeError: null is not an object (evaluating '_nativeEnabledCompleter.completeError') on overlapping enable() calls可能已有人在做 @FaizanUllahDev 于 18 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 1/5 1 小时以内 新手友好度 65/100
fluttercommunity/wakelock_plus#117 · 2 条评论 · 2 个 reaction ·
-
window不能编译未关闭
难度 3/5 1-2 天 新手友好度 35/100
-
难度 2/5 1-3 小时 新手友好度 55/100
查看 fluttercommunity/wakelock_plus 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
OscillateLabsLLC/ovos-gui-visage#52 ·
维护者通常 1 天内回复
-
bug triage
难度 2/5 1-3 小时 新手友好度 66/100
fluttercommunity/plus_plugins#4018 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
VeryGoodOpenSource/vgv_ai_cli#150 · 1 个 reaction ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 75/100
PATILYASHH/XPENC#206 · 1 条评论 ·