'Update data of navigated screen
I Have screen A,B. I route from screen A to B using
_routeToSelectLocation() {
Navigator.of(context).pushNamed(
'/search-location',
);
}
and then i something change in screen B and return to A. While returning to Screen A i want to update text present in A. For routing from B to A i m using
onPressed: () => Navigator.of(context).pop(),
Now, for updating values I'm using providers
MultiProvider(
providers: [
ChangeNotifierProvider.value(value: SearchByLocationNotify())
],
My tree Structure is like Home contains Screen A Screen B is not the part of Home (if I'm routing I guess)
Solution 1:[1]
you can await push function and pass something to pop();
_routeToSelectLocation() async {
final valueFromScreenB = await Navigator.of(context).pushNamed(
'/search-location',
);
}
onPressed: () => Navigator.of(context).pop(valueToReturn),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Xoltawn |
