搜索插件、代码仓与 APP 分类

插件详情v1.8.2

wakelock_plus

一个插件,可让您保持设备屏幕常亮,即防止在 Android、iOS、macOS、Windows、Linux 和 Web 上的屏幕进入休眠状态。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
268万
喜欢数
649
Pub 分数
160

安装插件

flutter pub add wakelock_plus

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

wakelock_plus 是一个 Flutter 插件,可防止设备屏幕进入休眠状态,跨 Android、iOS、Web、macOS、Windows 和 Linux 多个平台保持屏幕常亮。它非常适合需要持续显示屏幕的应用程序,例如视频播放器、导航应用或 kiosk 模式。该包提供了简单的 API 来启用或禁用唤醒锁,确保在不同平台上行为一致。它轻量且可无缝集成到现有的 Flutter 项目中。

适合场景

  • 视频播放
  • 导航应用
  • 自助服务模式
  • 数字标牌
  • 交互式教程
  • 长时间运行的进程

主要特点

  • 跨平台支持
  • 简单 API
  • 低电量影响
  • 应用退出时自动发布
  • 平台特定优化
  • 无需原生代码

适合对象

  • 媒体应用
  • 销售点系统
  • 教育工具
  • 演示应用
  • 需要不间断显示的应用程序

使用建议

  • 可能增加电池消耗
  • 某些平台需要用户权限
  • 不适用于后台任务
  • 可能干扰系统电源管理
  • 在不需要时应禁用
  • 如果过度使用,可能会产生可用性问题

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Wakelock Plus

GitHub stars Pub version

A continuation of the original Flutter plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping.

Supported platforms

Platform wakelock_plus support
Android ✅
iOS ✅
Web ✅
macOS ✅
Windows ✅
Linux ✅

Getting started

To learn more about the plugin and getting started, you can view the main package's README.

Plugin structure

This plugin plugin uses the federated plugins approach.

Android, iOS, macOS (via Hybrid Implementation), and Web use Platform Channels in their implementations. Windows and Linux are handled through Dart-only platform implementations.

The basic API is defined using pigeon. The pigeon files can be found in the pigeons directory in the main package. The API is defined in Dart in the wakelock_plus_platform_interface package.

The packages in this repo are the following:

Package Implementations
wakelock_plus Main plugin package + Android, iOS, macOS, Windows, Linux, and Web implementations
wakelock_plus_platform_interface Basic API definition & message handling

Contributing

If you want to contribute to this plugin, follow the contributing guide.

Origin

As stated before, this plugin is a continuation of the original wakelock plugin. That plugin was originally based on screen.

Specifically, the wakelock functionality was extracted into the wakelock plugin due to lack of maintenance by the author of the screen plugin.

For this library, the functionality remains the same as the original plugin, but has been completely refreshed (using latest Flutter standards and platform integration) with support for all six platforms currently supported by Flutter (Android, iOS, macOS, Windows, Linux, and Web).

Migrating from the wakelock Plugin

Simply replace the import statement with the one below:

import 'package:wakelock_plus/wakelock_plus.dart';

As well as replacing all the calls to Wakelock with WakelockPlus:

WakelockPlus.enable();
//...
WakelockPlus.disable();
//...
WakelockPlus.toggle(enable: true);

所属分类

依赖

依赖清单 6 项

源码仓库

使用此插件的项目

所在榜单