creativecreatorormaybenot

Pub improvements

  1 +## 0.1.0
  2 +
  3 +* Bumped version to indicate that the plugin is fully usable.
  4 +* Improved README's.
  5 +* Formatted Dart files.
  6 +
1 ## 0.0.1 7 ## 0.0.1
2 8
3 * The wakelock plugin allows you to toggle the Android and iOS wakelock 9 * The wakelock plugin allows you to toggle the Android and iOS wakelock
@@ -17,32 +17,36 @@ class _MyAppState extends State<MyApp> { @@ -17,32 +17,36 @@ class _MyAppState extends State<MyApp> {
17 Widget build(BuildContext context) => MaterialApp( 17 Widget build(BuildContext context) => MaterialApp(
18 home: Scaffold( 18 home: Scaffold(
19 body: Center( 19 body: Center(
20 - child: Column(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[  
21 - FlatButton(  
22 - child: const Text('enable wakelock'),  
23 - onPressed: () {  
24 - // The following code will enable the wakelock on Android or iOS using the wakelock plugin.  
25 - setState(() {  
26 - Wakelock.enableWakelock();  
27 - });  
28 - },  
29 - ),  
30 - FlatButton(  
31 - child: const Text('disable wakelock'),  
32 - onPressed: () {  
33 - // The following code will disable the wakelock on Android or iOS using the wakelock plugin.  
34 - setState(() {  
35 - Wakelock.disableWakelock();  
36 - });  
37 - },  
38 - ),  
39 - FutureBuilder(  
40 - future: Wakelock.isWakelockEnabled,  
41 - builder: (context, AsyncSnapshot<bool> snapshot) {  
42 - // The use of FutureBuilder is necessary here to await the bool value from isWakelockEnabled.  
43 - if (!snapshot.hasData) return Container(); // The Future is retrieved so fast that you will not be able to see any loading indicator.  
44 - return Text('wakelock is currently ${snapshot.data ? 'enabled' : 'disabled'}');  
45 - },  
46 - )  
47 - ])))); 20 + child: Column(
  21 + mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  22 + children: <Widget>[
  23 + FlatButton(
  24 + child: const Text('enable wakelock'),
  25 + onPressed: () {
  26 + // The following code will enable the wakelock on Android or iOS using the wakelock plugin.
  27 + setState(() {
  28 + Wakelock.enableWakelock();
  29 + });
  30 + },
  31 + ),
  32 + FlatButton(
  33 + child: const Text('disable wakelock'),
  34 + onPressed: () {
  35 + // The following code will disable the wakelock on Android or iOS using the wakelock plugin.
  36 + setState(() {
  37 + Wakelock.disableWakelock();
  38 + });
  39 + },
  40 + ),
  41 + FutureBuilder(
  42 + future: Wakelock.isWakelockEnabled,
  43 + builder: (context, AsyncSnapshot<bool> snapshot) {
  44 + // The use of FutureBuilder is necessary here to await the bool value from isWakelockEnabled.
  45 + if (!snapshot.hasData)
  46 + return Container(); // The Future is retrieved so fast that you will not be able to see any loading indicator.
  47 + return Text(
  48 + 'wakelock is currently ${snapshot.data ? 'enabled' : 'disabled'}');
  49 + },
  50 + )
  51 + ]))));
48 } 52 }
@@ -16,11 +16,13 @@ class Wakelock { @@ -16,11 +16,13 @@ class Wakelock {
16 16
17 /// This can simply be called using `Wakelock.enableWakelock()` and does not return anything. 17 /// This can simply be called using `Wakelock.enableWakelock()` and does not return anything.
18 /// You can await the [Future] to wait for the operation to complete. 18 /// You can await the [Future] to wait for the operation to complete.
19 - static Future<void> enableWakelock() => _channel.invokeMethod('toggleWakelock', {'enable': true}); 19 + static Future<void> enableWakelock() =>
  20 + _channel.invokeMethod('toggleWakelock', {'enable': true});
20 21
21 /// This can simply be called using `Wakelock.disableWakelock()` and does not return anything. 22 /// This can simply be called using `Wakelock.disableWakelock()` and does not return anything.
22 /// You can await the [Future] to wait for the operation to complete. 23 /// You can await the [Future] to wait for the operation to complete.
23 - static Future<void> disableWakelock() => _channel.invokeMethod('toggleWakelock', {'enable': false}); 24 + static Future<void> disableWakelock() =>
  25 + _channel.invokeMethod('toggleWakelock', {'enable': false});
24 26
25 /// You can simply use this function to toggle the wakelock using a [bool] value. 27 /// You can simply use this function to toggle the wakelock using a [bool] value.
26 /// ```dart 28 /// ```dart
@@ -28,9 +30,11 @@ class Wakelock { @@ -28,9 +30,11 @@ class Wakelock {
28 /// Wakelock.toggleWakelock(enable); 30 /// Wakelock.toggleWakelock(enable);
29 /// ``` 31 /// ```
30 /// You can await the [Future] to wait for the operation to complete. 32 /// You can await the [Future] to wait for the operation to complete.
31 - static Future<void> toggleWakelock(bool enable) => _channel.invokeMethod('toggleWakelock', {'enable': enable}); 33 + static Future<void> toggleWakelock(bool enable) =>
  34 + _channel.invokeMethod('toggleWakelock', {'enable': enable});
32 35
33 /// If you want to retrieve the current wakelock status, you will have to call [Wakelock.isWakelockEnabled] 36 /// If you want to retrieve the current wakelock status, you will have to call [Wakelock.isWakelockEnabled]
34 /// and await its result: `bool isWakelockEnabled = await Wakelock.isWakelockEnabled()` 37 /// and await its result: `bool isWakelockEnabled = await Wakelock.isWakelockEnabled()`
35 - static Future<bool> get isWakelockEnabled => _channel.invokeMethod('isWakelockEnabled'); 38 + static Future<bool> get isWakelockEnabled =>
  39 + _channel.invokeMethod('isWakelockEnabled');
36 } 40 }
1 name: wakelock 1 name: wakelock
2 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. 2 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.
3 -version: 0.0.1 3 +version: 0.1.0
4 author: creativecreatorormaybenot <19204050+creativecreatorormaybenot@users.noreply.github.com> 4 author: creativecreatorormaybenot <19204050+creativecreatorormaybenot@users.noreply.github.com>
5 homepage: https://github.com/creativecreatorormaybenot/wakelock 5 homepage: https://github.com/creativecreatorormaybenot/wakelock
6 6
@@ -11,6 +11,8 @@ dependencies: @@ -11,6 +11,8 @@ dependencies:
11 flutter: 11 flutter:
12 sdk: flutter 12 sdk: flutter
13 13
  14 + meta: 1.17
  15 +
14 dev_dependencies: 16 dev_dependencies:
15 flutter_test: 17 flutter_test:
16 sdk: flutter 18 sdk: flutter