Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Idiomatic way to update a Flutter page after data was edited by another page?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading