Home > Net >  Flutter call setState after Get.back()
Flutter call setState after Get.back()

Time:09-09

I need to reload page after Get.back(). How to do it? How to call any method on previous page as soon as possible after using Get.back()? For example:

  1. I'm on Page1
  2. Go to Page2
  3. Use Get.back(), so user back to Page1
  4. Usually user now see Page1 exactly like when he leave Page1. How to reload now view Page1?

Maybe is any method to override what I can call every time after navigate one page back? This method must come from Page1, not from Page2

CodePudding user response:

you can do await while navigating to page 2.

Example:

await Get.to(()=> Page2());
setState({
   // perform update
});

the setState will get fired once you come back to page 1 from page 2

CodePudding user response:

on Page 2: You need to write this

Get.back(result: true);

on Page 1: wait for response

var response = await Get.to(()=> Page2());
if(response){setState({
   // perform update
});}
  • Related