Reputation: 1050
I have 2 pages PAGE A and PAGE B. I navigate form PAGE A -> PAGE B and do edit some data, or toggle a setting. Now I want to navigate form PAGE B -> PAGE A and also what that a parameter would be send on navigator pop method. Now my question:
How I can access to these parameter in PAGE A?
Navigator.pop(context, this.selectedEquipmentId);
Upvotes: 1
Views: 336
Reputation: 834
In fact you got to return something when you ends PageA. I put you an exemple with a popup to select an adress i made recently, this work exactly the same if this is not a popup.
Future<PlacesDetailsResponse> showAdressPicker({@required BuildContext context}) async {
assert(context != null);
return await showDialog<PlacesDetailsResponse>(
context: context,
builder: (BuildContext context) => AdressPickerComponent(),
);
}
You can send a result from Navigator.pop(...) and get it from PageA
Navigator.pop(context, result)
Just put anything you want in result, (here i created a class named PlacesDetailsResponse, use yours or just Int, String...). Now In pageA when you call this
showAdressPicker(context: context).then((PlacesDetailsResponse value) {
//do whatever you want here
// this fires when PageB call previous to PageA
});
Upvotes: 2