New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wakelock.enable()
does not work on Android
#160
Comments
Hi, thanks for using the package! Without further detail, it will be impossible to help you here. The package does work for most users after all. Which phone are you using? |
@creativecreatorormaybenot |
@rohitvishwakarma1819 I do not have this device here to test. Can you test on a different device and confirm that the wakelock is working, i.e. that you are using it properly? |
Same. Doesn't work with Android 11 |
@itssidhere hi - thanks for reporting. I have the same request for you, i.e. sharing how you are using it / testing with different devices for reproduction ✌️ |
@creativecreatorormaybenot seems like it's the issue with latest flutter version 2.9 can't be sure though I am using poco X3 Pro and yes it doesn't work on any of my devices |
@itssidhere I checked again on my devices and I cannot reproduce. Without further input, I cannot help you here - unfortuantely. You will at least have to either debug the issue yourself and figure out where it comes from or post a reproducible sample. My advice would be to use the example app for testing this. |
I have tested wakelock ^0.6.0+1 on Samsung A21s with Android 11. I'm using Flutter 2.8.1 stable, everything is working fine 👍 |
@creativecreatorormaybenot I agree I might have to look in detail. I will do so and update you. Thanks. |
Wakelock.enable()
does not work on Android
Doens't work on my Android 11 Xiaomi 10 lite 5g. |
Same here, using a Moto G7 Plus, tho with Lineage OS 18.1 which is based on Android 11.
Also, just to make sure I did not use it incorrectly? 😅 import 'package:flutter/material.dart';
import 'package:wakelock/wakelock.dart';
void main() {
Wakelock.enable();
runApp(MaterialApp(
initialRoute: '/home',
routes: {
...
},
));
} |
@bunnythelifeguard Can you try calling If that does not fix it, there definitely is an issue with the plugin |
@creativecreatorormaybenot looks like calling it inside a build took care of it, device did not go to sleep so far. @override
Widget build(BuildContext context) {
Wakelock.enable();
return const Scaffold(
body: Text("loading"),
);
} Where would the most central/earliest opportunity be to call it, or does one have to call it inside every build? (Still learning the framework ^^) |
@bunnythelifeguard Calling it inside of A third option that I see is the following: void main() {
Wakelock.enable();
runApp(..);
} Will not work. That is because the method channels have not yet been initialized. void main() {
WidgetsFlutterBinding.ensureInitialized();
Wakelock.enable();
runApp(..);
} |
@creativecreatorormaybenot Thanks for explaining, brother 🙂 Just as an fyi: I did not call anything besides |
Worked for me, I suggest to add in the README.
|
That is great to hear @pdivita! Which fix are you referring to? |
In my case in a new project both worked. |
Wakelock started working after I've added |
I just created a bank flutter application and added
Wakelock.enable();
as the first line inside main() method.I doesn't prevent my app from going to sleep.
The text was updated successfully, but these errors were encountered: