Closed callawey closed 4 years ago
Hi @callawey π Thanks for opening an issue!
The approach you've provided seems totally reasonable. One suggestion for potentially improving/simplifying things would be to use nested Navigators
for each "feature" or "flow" and that way you can provide the blocs required above the Navigator
and not need to pass the blocs through each route push via BlocProvider.value
.
For example:
BlocProvider(
create: (context) => FeatureABloc(),
child: Navigator(onGenerateRoute: (_) => FeatureAPage.route()),
);
class FeatureAPage extends StatelessWidget {
static Route route() {
return MaterialPageRoute(builder: (_) => FeatureAPage());
}
@override
Widget build(BuildContext context) { ... }
}
With this approach the FeatureABloc
instance is available even across multiple MaterialPageRoutes within FeatureAPage
. Hope that helps π
Closing for now but feel free to comment with additional questions and I'm happy to continue the conversation π
There is very good amount of examples but not a single complex one
Now lets say this is my route design
Home->Visit Plans->Visit Plan Rows->Retailer Detail->Sales (on sales, products, basket, calculations etc.)
Now from top to down, meaning on creating sales, i have to update all of them till Visit Plans route.
For example, Updating is visited flag for retailer, or Completed flag for Visit Plan when sales created.
I already implemented an architecture for this with a Bloc for each route and providing previous BLoc on child route but i am not sure is this the correct way to handle it. For now, its working perfectly but still i want some opinion.
This is my router class with Blocs from top to sales screens: