In Flutter let a route /a
is displayed. Then I press Edit button what pushes route /b
. The route /b
changes data in the SQLite DB and then I call Navigator.pop
so returning to the route /a
.
Now route /a
displays the old (unedited) version of the data.
I need in some way route /b
to send to route /a
an "update" signal.
How to do it? The best solution I came to is to pass the widget /a
(or better its state) in pushNamed
arguments
parameter. This is awkward however, particularly because this requires onUpdate
handler to be passed down to the subwidget of /a
that actually reads data from DB possibly through a chain of several widgets. Is the way that I described here the idiomatic Flutter way, or is there a better solution?
Wait for the result from another route.
final result = await Navigator.push(...);
Return the result.
Navigator.pop(context, 'Hello!');
See Return data from a screen for details.