Hi @felangel and thanks for this amazing library :)
I've an application which, within the body of a Scaffold, renders a list of items and the FloatingActionButton of such Scaffold is used to open a dialog which the user can use to add a new item.
In such scenario, I've at the moment 2 blocs: one for adding the new item and one for listing the available items in a paginated way.
I've the requirement to refresh the list of items as soon as the new item is added, but I cannot imagine how to it with flutter_bloc in a "nice" way.
Since the 2 blocs are under different contexts, I cannot really read the bloc handling the list from the one adding the new item.
One way I can imagine is to lift the state of the list of items up, so that the Scaffold is child of the BlocProvider instead of being the latter the child of the body of the former, but it would be really ugly because the Scaffold renders a BottomNavigationBar with 3 items (and therefore 3 pages) and this would mean define a MultiBlocProvider which provides the Bloc to each page.
As a result, the bloc managing the list (and, in the future, the ones from the other pages) would be really out of scope in my opinion (in the sense and its scope is way broader than it should be).
What do you suggest from your point of view? How would you design the interaction with the blocs in such scenario?
Kind regards and thanks in advance,
Cosimo
Hi @felangel and thanks for this amazing library :)
I've an application which, within the body of a
Scaffold, renders a list of items and theFloatingActionButtonof suchScaffoldis used to open a dialog which the user can use to add a new item.In such scenario, I've at the moment 2 blocs: one for adding the new item and one for listing the available items in a paginated way.
I've the requirement to refresh the list of items as soon as the new item is added, but I cannot imagine how to it with
flutter_blocin a "nice" way.Since the 2 blocs are under different contexts, I cannot really read the bloc handling the list from the one adding the new item.
One way I can imagine is to lift the state of the list of items up, so that the
Scaffoldis child of theBlocProviderinstead of being the latter the child of the body of the former, but it would be really ugly because theScaffoldrenders aBottomNavigationBarwith 3 items (and therefore 3 pages) and this would mean define aMultiBlocProviderwhich provides theBlocto each page.As a result, the bloc managing the list (and, in the future, the ones from the other pages) would be really out of scope in my opinion (in the sense and its scope is way broader than it should be).
What do you suggest from your point of view? How would you design the interaction with the blocs in such scenario?
Kind regards and thanks in advance,
Cosimo