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 ?
CodePudding user response:
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.
});
CodePudding user response:
Add a boolean parameter to your screen and when you want the popup so give it a True:
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);