How to go back and refresh the previous page in Flutter?
How to go back and refresh the previous page in Flutter?
*********************************************************************************
> You can trigger the API call when you navigate back to the first page like this pseudo-code
class PageOne extends StatefulWidget {
@override
_PageOneState createState() => new _PageOneState();
}
class _PageOneState extends State<PageOne> {
_getRequests()async{
}
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Center(
child: new RaisedButton(onPressed: ()=>
Navigator.of(context).push(new MaterialPageRoute(builder: (_)=>new PageTwo()),)
.then((val)=>val?_getRequests():null),
),
));
}
}
class PageTwo extends StatelessWidget {
@override
Widget build(BuildContext context) {
//somewhere
Navigator.pop(context,true);
}

Comments
Post a Comment