Reputation: 47
I pass a page with this code below.
Navigator.push(context,
MaterialPageRoute(builder: (context) => FileFolder()));
for example, I change some data in FileFolder();
page. And I want to get this data to my first page what I change data. I use Navigator.pop(context);
but this code is not run initstate((){});
. How can I refresh my first page?
Upvotes: 0
Views: 806
Reputation: 1252
//first page
Future data = await Navigator.push(context,
MaterialPageRoute(builder: (context) => FileFolder()));
setState(() {
myData = data;
});
//second page FileFolder
Map data = {};
Navigator.pop(context,data);
Upvotes: 2
Reputation: 1643
You can write your code inside initstate((){});
method like below:
Future.delayed(Duration.zero, () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => FileFolder()));
});
Upvotes: 0