0

I'm working with the flutter_bloc library. Imagine the situation, that you are navigating deep in your app and every screen on the navigationstack presents data (slightly differnet because otherwise it wouldn't make sense), that can be modified by the user. Because we are using Bloc, every screen is connected to it's own bloc. Now, the user modifies the data.

My question: How can I tell the other Blocs/screens to rebuild with the updated data?

To my understanding, the blocs on the routes which I'm not currently viewing, get closed. So they don't listen to events anymore. EDIT: This assumption is wrong, see answer.

Daniel Wei
  • 51
  • 4
  • Then you use the Navigator.push* you receive a Future, you can use 'then' to know when the view pop and send a RefreshEvent to the bloc so the state gets refreshed. – Ricardo Markiewicz Dec 13 '19 at 13:34
  • Ok haven't thought about this yet but if you're getting the data out of a database with delay, it wouldn't be very fluent for the user. I thought about something like scoped model, that I can somehow update all screens which some smart implementation of bloc. – Daniel Wei Dec 13 '19 at 20:15

1 Answers1

0

Final answer. My assumption was wrong. Blocs don't get closed, if the route is still on the navigation stack. So you can still add events to Blocs, which are on other routes.

Daniel Wei
  • 51
  • 4