didChangeAppLifecycleState doesn't work as expected

1,099 views
Skip to first unread message

Tony Seng

unread,
Dec 3, 2019, 3:55:04 AM12/3/19
to Flutter Development (flutter-dev)

I hope I understand how didChangeAppLifecycleState worked correctly.

I have page A and page B . When I click the back device button from page B ( Navigator.of(context).pop();), I expect didChangeAppLifecycleState in pageA will get called, but it doesn't.


PageA


class _ABCState extends State<ABCrList> with WidgetsBindingObserver {
@override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
            ....
  }

  @override
  void dispose() {
    WidgetsBinding.instance.removeObserver(this);
    super.dispose();
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    if (state == AppLifecycleState.resumed) {
      setState(() {
        print(...);
      });
    }else{
      print(state.toString());
    }
  }

....
 

Andy Greenshaw

unread,
Dec 3, 2019, 4:27:28 AM12/3/19
to Flutter Development (flutter-dev), Tony Seng
No, you don’t understand.
It’s for the app life cycle, not pages (widgets).

So if the app goes into the background, or is resumed from the background etc.
--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/04c1e0d1-bf67-4f45-94d5-0c08cd70400a%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages