Reputation: 1983
This is my App's flow:
How do I update the Home Page when I press back and return to it from the MaterialPageRoute? I attempted to use the setState
method in the dispose()
method of MaterialPageRoute, but it gave me an error.
Upvotes: 0
Views: 472
Reputation: 1983
Actually, the Home Page is automatically updated, however I made a mistake by updating the variable within the dispose()
method, which is invoked after the Home Page has been updated.
Upvotes: 0
Reputation: 4666
You can use Navigator.push(context,MaterialPageRoute(builder: (context) => TheSecondPage())).then((value) { setState(() {});
thus when you pop from TheSecondPage()
you will immediatelly call the setState
refreshing the page.
Upvotes: 1