Want 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 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); } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.