-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.platform-iosiOS applications specificallyiOS applications specifically
Description
I have the following code which will replace the child with a container when the app goes to inactive or paused state.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
body: SecureScreen(
child: Container(
color: Colors.red,
),
),
),
);
}
}
class SecureScreen extends StatefulWidget {
final Widget child;
SecureScreen({@required this.child});
@override
SecureScreenState createState() => SecureScreenState();
}
class SecureScreenState extends State<SecureScreen>
with WidgetsBindingObserver {
AppLifecycleState _notification;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
print(state.toString());
setState(() {
_notification = state;
});
}
@override
Widget build(BuildContext context) {
return (_notification == AppLifecycleState.paused ||
_notification == AppLifecycleState.inactive)
? Container(
color: Colors.greenAccent,
)
: widget.child;
}
}
So when I double click the home button in IOS to view all the open applications, it is triggering
"inactive" state but it is not calling the build() method to render container with greenAccent color.
I have attached the screenshot for you reference.
djkloop, Veteraanikoodari, emadd, hariom08, vplme and 15 more
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.platform-iosiOS applications specificallyiOS applications specifically
