# wakelock-0.2.1+1 **Repository Path**: zexzcm/wakelock-021-1 ## Basic Information - **Project Name**: wakelock-0.2.1+1 - **Description**: No description available - **Primary Language**: Unknown - **License**: BSD-3-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-03-18 - **Last Updated**: 2021-03-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # wakelock [![Pub version](https://img.shields.io/pub/v/wakelock.svg)](https://pub.dev/packages/wakelock) [![GitHub stars](https://img.shields.io/github/stars/creativecreatorormaybenot/wakelock.svg)](https://github.com/creativecreatorormaybenot/wakelock) [![Twitter Follow](https://img.shields.io/twitter/follow/creativemaybeno?label=Follow&style=social)](https://twitter.com/creativemaybeno) Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, and web. --- The plugin allows you to enable and toggle the screen wakelock on Android, iOS, and web, which prevents the screen from turning off automatically. Essentially, this allows you to keep the device awake, i.e. prevent the device from sleeping. ## Usage To use this plugin, follow the [installing guide](https://pub.dev/packages/wakelock/install). ### Implementation Everything in this plugin is controlled via the [`Wakelock` class](https://pub.dev/documentation/wakelock/latest/wakelock/Wakelock-class.html). If you want to enable the wakelock, i.e. keep the device awake, you can simply call [`Wakelock.enable`](https://pub.dev/documentation/wakelock/latest/wakelock/Wakelock/enable.html) and to disable it again, you can use [`Wakelock.disable`](https://pub.dev/documentation/wakelock/latest/wakelock/Wakelock/disable.html): ```dart import 'package:wakelock/wakelock.dart'; // ... // The following line will enable the Android and iOS wakelock. Wakelock.enable(); // The next line disables the wakelock again. Wakelock.disable(); ``` For more advanced usage, you can pass a `bool` to [`Wakelock.toggle`](https://pub.dev/documentation/wakelock/latest/wakelock/Wakelock/toggle.html) to enable or disable the wakelock and also retrieve the current wakelock status using [`Wakelock.isEnabled`](https://pub.dev/documentation/wakelock/latest/wakelock/Wakelock/isEnabled.html): ```dart import 'package:wakelock/wakelock.dart'; // ... // The following lines of code toggle the wakelock based on a bool value. bool enable = true; // The following statement enables the wakelock. Wakelock.toggle(enable: enable); enable = false; // The following statement disables the wakelock. Wakelock.toggle(enable: enable); // If you want to retrieve the current wakelock status, // you will have to be in an async scope // to await the Future returned by `enabled`. bool wakelockEnabled = await Wakelock.enabled; ``` If you want to wait for the wakelock toggle to complete (which takes an insignificant amount of time), you can also `await` any of `Wakelock.enable`, `Wakelock.disable`, and `Wakelock.toggle`. ## Learn more If you want to learn more about how this plugin works, how to contribute, etc., you can read through the [main README on GitHub](https://github.com/creativecreatorormaybenot/wakelock).