skip to Main Content

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


  1. Use this on navigator push Navigator.push(context).then((value)=>setState((){}); when it pop the screen it will run the setState

    Login or Signup to reply.
  2. Use this sentence to go to the second page so the function will wait second screen to close

    bool result = await Navigator.push(context);
    if(result){setState((){});} 
    

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search