creativecreatorormaybenot

Pub improvements

## 0.1.0
* Bumped version to indicate that the plugin is fully usable.
* Improved README's.
* Formatted Dart files.
## 0.0.1
* The wakelock plugin allows you to toggle the Android and iOS wakelock
... ...
... ... @@ -17,32 +17,36 @@ class _MyAppState extends State<MyApp> {
Widget build(BuildContext context) => MaterialApp(
home: Scaffold(
body: Center(
child: Column(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[
FlatButton(
child: const Text('enable wakelock'),
onPressed: () {
// The following code will enable the wakelock on Android or iOS using the wakelock plugin.
setState(() {
Wakelock.enableWakelock();
});
},
),
FlatButton(
child: const Text('disable wakelock'),
onPressed: () {
// The following code will disable the wakelock on Android or iOS using the wakelock plugin.
setState(() {
Wakelock.disableWakelock();
});
},
),
FutureBuilder(
future: Wakelock.isWakelockEnabled,
builder: (context, AsyncSnapshot<bool> snapshot) {
// The use of FutureBuilder is necessary here to await the bool value from isWakelockEnabled.
if (!snapshot.hasData) return Container(); // The Future is retrieved so fast that you will not be able to see any loading indicator.
return Text('wakelock is currently ${snapshot.data ? 'enabled' : 'disabled'}');
},
)
]))));
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
FlatButton(
child: const Text('enable wakelock'),
onPressed: () {
// The following code will enable the wakelock on Android or iOS using the wakelock plugin.
setState(() {
Wakelock.enableWakelock();
});
},
),
FlatButton(
child: const Text('disable wakelock'),
onPressed: () {
// The following code will disable the wakelock on Android or iOS using the wakelock plugin.
setState(() {
Wakelock.disableWakelock();
});
},
),
FutureBuilder(
future: Wakelock.isWakelockEnabled,
builder: (context, AsyncSnapshot<bool> snapshot) {
// The use of FutureBuilder is necessary here to await the bool value from isWakelockEnabled.
if (!snapshot.hasData)
return Container(); // The Future is retrieved so fast that you will not be able to see any loading indicator.
return Text(
'wakelock is currently ${snapshot.data ? 'enabled' : 'disabled'}');
},
)
]))));
}
... ...
... ... @@ -16,11 +16,13 @@ class Wakelock {
/// This can simply be called using `Wakelock.enableWakelock()` and does not return anything.
/// You can await the [Future] to wait for the operation to complete.
static Future<void> enableWakelock() => _channel.invokeMethod('toggleWakelock', {'enable': true});
static Future<void> enableWakelock() =>
_channel.invokeMethod('toggleWakelock', {'enable': true});
/// This can simply be called using `Wakelock.disableWakelock()` and does not return anything.
/// You can await the [Future] to wait for the operation to complete.
static Future<void> disableWakelock() => _channel.invokeMethod('toggleWakelock', {'enable': false});
static Future<void> disableWakelock() =>
_channel.invokeMethod('toggleWakelock', {'enable': false});
/// You can simply use this function to toggle the wakelock using a [bool] value.
/// ```dart
... ... @@ -28,9 +30,11 @@ class Wakelock {
/// Wakelock.toggleWakelock(enable);
/// ```
/// You can await the [Future] to wait for the operation to complete.
static Future<void> toggleWakelock(bool enable) => _channel.invokeMethod('toggleWakelock', {'enable': enable});
static Future<void> toggleWakelock(bool enable) =>
_channel.invokeMethod('toggleWakelock', {'enable': enable});
/// If you want to retrieve the current wakelock status, you will have to call [Wakelock.isWakelockEnabled]
/// and await its result: `bool isWakelockEnabled = await Wakelock.isWakelockEnabled()`
static Future<bool> get isWakelockEnabled => _channel.invokeMethod('isWakelockEnabled');
static Future<bool> get isWakelockEnabled =>
_channel.invokeMethod('isWakelockEnabled');
}
... ...
name: wakelock
description: Wakelock is a Flutter plugin that allows you to easily toggle the Android and iOS screen wakelock on or off in order to prevent the screen from automatically turning off.
version: 0.0.1
version: 0.1.0
author: creativecreatorormaybenot <19204050+creativecreatorormaybenot@users.noreply.github.com>
homepage: https://github.com/creativecreatorormaybenot/wakelock
... ... @@ -11,6 +11,8 @@ dependencies:
flutter:
sdk: flutter
meta: 1.17
dev_dependencies:
flutter_test:
sdk: flutter
... ...