0

I have a scenario where i have one popup in screen A .It will be triggerd from initstate() . User can navigate to screen B after clicking on button inside the popup . How can i show the popup if user come back to screen 1 by clicking on arrow back button ?

vkas dev
  • 41
  • 3

2 Answers2

1

You can achieve with the help of .then() : https://api.flutter.dev/flutter/dart-async/Future/then.html

                         Navigator.of(context)
                             .push(CupertinoPageRoute<Screen1>(
                              builder: (context) => Screen2(
                                ))).then((value) {

                             //ShowPopUpMenu() <-- Your PopUpMenu.

                          });
Yashraj
  • 1,025
  • 1
  • 5
  • 22
0

Add a boolean parameter to your screen if you want the popup:

class PopScreen extends StatefulWidget {
  PopScreen (this.displayPopup);
  final bool displayPopup;
  @override
  _PopScreenState createState() => _PopScreenState();
}

class _PopScreenState extends State<PopScreen> {
  @override
  void initState() {
    super.initState();
    if(widget.displayPopup){
      // display your popup here
    }
  }
}

call to the navigator:

Navigator.pushNamed(context, '/yourscreen', arguments: true);
EyaS
  • 477
  • 3
  • 9