I use to pass a BLoC instance to a new route like so :
Navigator.of(context).push<void(FavoriteDetailPage.route(_favoriteBloc));
class FavoriteDetailPage extends StatelessWidget {
const FavoriteDetailPage({super.key});
static Route route(FavoriteBloc favoriteBloc) {
return MaterialPageRoute<void>(
settings: const RouteSettings(name: 'favorite_detail'),
builder: (_) => BlocProvider.value(
value: favoriteBloc,
child: FavoriteDetailPage(),
),
);
}
...
}
I'm in the process of migrating my app routing to go_router & can't find how to the same. -> Provide the same bloc instance to a new route, as go_router parameters
can only be String
I could provide the BLoC above my MaterialApp
to make it available to my all app but I don't want to provide it to my all app (just to those two sub routes)