I am building a flutter app with BloC
and go_router
.
I have a few routes (steps) that correspond to a “input form”. They share a bloc that gets filled with info over the steps.
I want to have these “form” routes isolated, but yet share the bloc data within.
Isolated, meaning that I don’t want to have a global bloc provider in the root, since I want it to reset every time the form is initiated. And also, lazily since it’s a rare occasion.
And shared, meaning that each step has access to the data from the previous step.
I tried ShellRoute
with its builder
, but it still gets rebuild on every routing action, so the provider is getting reset. And I want to keep the data.
Ofc, there are ways to pass bloc from one route to another, through extra for example. But this is pretty cumbersome and prone to errors.
Any thoughts?
1