Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
flutter_wakelock
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
creativecreatorormaybenot
2019-07-07 01:19:07 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
40a7e024150de4a6f201e54e431f2bcb0f15f99d
40a7e024
1 parent
0c893c56
Pub improvements
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
8 deletions
CHANGELOG.md
example/lib/main.dart
lib/wakelock.dart
pubspec.yaml
CHANGELOG.md
View file @
40a7e02
## 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
...
...
example/lib/main.dart
View file @
40a7e02
...
...
@@ -17,7 +17,9 @@ class _MyAppState extends State<MyApp> {
Widget
build
(
BuildContext
context
)
=>
MaterialApp
(
home:
Scaffold
(
body:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
<
Widget
>[
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
<
Widget
>[
FlatButton
(
child:
const
Text
(
'enable wakelock'
),
onPressed:
()
{
...
...
@@ -40,8 +42,10 @@ class _MyAppState extends State<MyApp> {
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'}
'
);
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'}
'
);
},
)
]))));
...
...
lib/wakelock.dart
View file @
40a7e02
...
...
@@ -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'
);
}
...
...
pubspec.yaml
View file @
40a7e02
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
...
...
Please
register
or
login
to post a comment