creativecreatorormaybenot

0.1.2

## 0.1.2
* Changed `Wakelock.toggle`'s parameter to a named parameter.
* Improved iOS implementation.
## 0.1.1+2
* Made the plugin description more concise.
... ...
... ... @@ -30,13 +30,13 @@ import 'package:wakelock/wakelock.dart';
// ...
// The following lines of code toggle the wakelock based on a bool value.
bool enable = true;
bool on = true;
// The following statement enables the wakelock.
Wakelock.toggle(enable);
Wakelock.toggle(on: on);
enable = false;
on = false;
// The following statement disables the wakelock.
Wakelock.toggle(enable);
Wakelock.toggle(on: on);
// If you want to retrieve the current wakelock status,
// you will have to be in an async scope
... ...
... ... @@ -26,6 +26,7 @@ class _MyAppState extends State<MyApp> {
// The following code will enable the wakelock on Android or iOS using the wakelock plugin.
setState(() {
Wakelock.enable();
// You could also use Wakelock.toggle(on: true);
});
},
),
... ... @@ -35,6 +36,7 @@ class _MyAppState extends State<MyApp> {
// The following code will disable the wakelock on Android or iOS using the wakelock plugin.
setState(() {
Wakelock.disable();
// You could also use Wakelock.toggle(on: false);
});
},
),
... ...
... ... @@ -12,11 +12,16 @@
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
if ([@"toggle" isEqualToString:call.method]) {
NSNumber *enable = call.arguments[@"enable"];
[[UIApplication sharedApplication] setIdleTimerDisabled:enable.boolValue];
result(nil);
NSNumber *enabled = [NSNumber numberWithBool:[[UIApplication sharedApplication] isIdleTimerDisabled]];
if([enable isEqualToNumber:enabled]) {
result(nil);
} else {
[[UIApplication sharedApplication] setIdleTimerDisabled:enable.boolValue];
result(nil);
}
} else if ([@"isEnabled" isEqualToString:call.method]) {
bool enabled = [[UIApplication sharedApplication] isIdleTimerDisabled];
result([NSNumber numberWithBool:enabled]);
result([NSNumber numberWithBool:[[UIApplication sharedApplication] isIdleTimerDisabled]]);
} else {
result(FlutterMethodNotImplemented);
}
... ...
... ... @@ -26,12 +26,16 @@ class Wakelock {
/// You can simply use this function to toggle the wakelock using a [bool] value.
/// ```dart
/// bool enable = true;
/// Wakelock.toggle(enable);
/// // This line keeps the screen on.
/// Wakelock.toggle(on: true);
///
/// bool turnOnWakelock = false;
/// // The following line disables the wakelock.
/// Wakelock.toggle(on: turnOnWakelock);
/// ```
/// You can await the [Future] to wait for the operation to complete.
static Future<void> toggle(bool enable) =>
_channel.invokeMethod('toggle', {'enable': enable});
static Future<void> toggle({bool on}) =>
_channel.invokeMethod('toggle', {'enable': on});
/// If you want to retrieve the current wakelock status, you will have to call [Wakelock.isEnabled]
/// and await its result: `bool isEnabled = await Wakelock.isEnabled()`
... ...
name: wakelock
description: This Flutter plugin allows you to keep Android and iOS devices awake, i.e. prevent them from sleeping by toggling the wakelock of the phone or tablet on or off.
version: 0.1.1+2
version: 0.1.2
author: creativecreatorormaybenot <19204050+creativecreatorormaybenot@users.noreply.github.com>
homepage: https://github.com/creativecreatorormaybenot/wakelock
... ...