https://github.com/fluttercommunity/wakelock_plus
Flutter plugin that allows you to keep the device screen awake on Android, iOS, macOS, Windows, Linux, and web.
https://github.com/fluttercommunity/wakelock_plus
Last synced: about 1 year ago
JSON representation
Flutter plugin that allows you to keep the device screen awake on Android, iOS, macOS, Windows, Linux, and web.
- Host: GitHub
- URL: https://github.com/fluttercommunity/wakelock_plus
- Owner: fluttercommunity
- License: bsd-3-clause
- Created: 2023-06-20T03:47:12.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-24T17:38:49.000Z (about 1 year ago)
- Last Synced: 2025-04-24T18:38:45.643Z (about 1 year ago)
- Language: Dart
- Size: 456 KB
- Stars: 79
- Watchers: 4
- Forks: 63
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Wakelock Plus
[](https://github.com/fluttercommunity/wakelock_plus) [](https://pub.dev/packages/wakelock_plus)
A continuation of the original Flutter [plugin](https://github.com/creativecreatorormaybenot/wakelock)
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](https://github.com/fluttercommunity/wakelock_plus/blob/main/wakelock/README.md).
### Plugin structure
This plugin plugin uses the [federated plugins approach](https://flutter.dev/docs/development/packages-and-plugins/developing-packages#federated-plugins).
Android, iOS, macOS (via Hybrid Implementation), and Web use Platform Channels in their implementations.
Windows and Linux are handled through [Dart-only platform implementations](https://docs.flutter.dev/packages-and-plugins/developing-packages#dart-only-platform-implementations).
The basic API is defined using [`pigeon`](https://pub.dev/packages/pigeon). The pigeon files can be found in the [`pigeons` directory](https://github.com/fluttercommunity/wakelock_plus/tree/main/wakelock/pigeons)
in the main package. The API is defined in Dart in the [`wakelock_plus_platform_interface` package](https://github.com/fluttercommunity/wakelock_plus/tree/main/wakelock_plus_platform_interface).
The packages in this repo are the following:
| Package | Implementations |
|-------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| [`wakelock_plus`](https://github.com/fluttercommunity/wakelock_plus/tree/main/wakelock) | Main plugin package + Android, iOS, macOS, Windows, Linux, and Web implementations |
| [`wakelock_plus_platform_interface`](https://github.com/fluttercommunity/wakelock_plus/tree/main/wakelock_platform_interface) | Basic API definition & message handling |
## Contributing
If you want to contribute to this plugin, follow the [contributing guide](https://github.com/fluttercommunity/wakelock_plus/blob/main/.github/CONTRIBUTING.md).
## Origin
As stated before, this plugin is a continuation of the original [wakelock](https://pub.dev/packages/wakelock) plugin.
That plugin was originally based on [`screen`](https://pub.dev/packages/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:
```dart
import 'package:wakelock_plus/wakelock_plus.dart';
```
As well as replacing all the calls to `Wakelock` with `WakelockPlus`:
```dart
WakelockPlus.enable();
//...
WakelockPlus.disable();
//...
WakelockPlus.toggle(enable: true);
```