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 ?
Asked
Active
Viewed 753 times
0
-
1To get a better answer, post some code. How are you currently opening the screen? – MSpeed Sep 23 '21 at 13:56
-
Please provide enough code so others can better understand or reproduce the problem. – Community Oct 01 '21 at 18:00
2 Answers
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