-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
Flutter : AppLifecycleState not work if devices in locked screen #47868
Comments
Hello @zgramming ! Thank you for posting an issue. |
Flutter doctor -v
|
Closing this as not reproducible on the latest master flutter doctor -v
Code sampleimport 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
AppLifecycleState previous;
Color color = Colors.red;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Sample',
home: Scaffold(
appBar: AppBar(
title: Text('Sample'),
),
body: Center(
child: GestureDetector(
onTap: () => setState(() => color = Colors.white),
child: Container(
color: color,
)),
),
),
);
}
@override
void initState() {
WidgetsBinding.instance.addObserver(this);
super.initState();
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
print(state);
if ((previous == AppLifecycleState.paused ||
previous == AppLifecycleState.inactive ||
previous == AppLifecycleState.detached) &&
state == AppLifecycleState.resumed) setState(() => color = Colors.red);
previous = state;
}
} @zgramming If you are still experiencing this on the latest stable or any other channel, please provide a minimal complete reproducible code sample and your |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
I use AppLifeycleState to detect Behaviour my app when the user using it. For detect my app not being used, i used
Because i want detect if my App not being used for 1 second, i throw user to Confirmation Fingerprint (Like Whatsapp). Everything is fine i can detect if my app not being used if user press recent app, Home button and throw user to Confirmation Fingerprint if user comeback again.
But the problem is , When devices screen in locked up then it opened again , user not throwing to Confirmation Fingerprint.
I surely can see in console my app is AppLifecycleState.paused and AppLifecycleState.inActive, but strangely if i hot reload ctrl +s in my IDE my app throwing me to Confirmation Fingerprint.
Why can be like this ?
Working 1
Working 2
Not Working !
Source Code AppLifecycleState
The text was updated successfully, but these errors were encountered: