i am creating a social media like app, when user clicks on post ,it redirects to a commentpage,in commentspage data is coming from a seperate API,so when go back using Navigator.pop(context), the data in home is not updated, if pressed like button,its not reflecting in ui, but updating in Api,
i wrapped Navigator with setstate but its not reflecting,
2
Answers
Use this on navigator push
Navigator.push(context).then((value)=>setState((){});
when it pop the screen it will run the setStateUse this sentence to go to the second page so the function will wait second screen to close
when u close the second screen use this sentence
Navigator.pop(context, true);
so when u comment has been posted successfully, u will back to screen one and complete the function if result boolean is true, else do nothing.