The main problem is not your navigation, it's your Bloc, what happens is that when you enter the PokemonDetailsView page, with the BlocBuilder<PokemonDetailsBloc, PokemonDetailsState> it cannot find its provider (the one in the main) but, if we go directly there, you have it written, right ?
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Material App',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.red,
),
home: MultiBlocProvider( // here is the problem
providers: [
BlocProvider<PokemonBloc>(
create: (context) =>
PokemonBloc()..add(const PokemonPageRequestEvent(page: 0))),
BlocProvider<PokemonDetailsBloc>(
create: (context) => PokemonDetailsBloc()),
],
child: const PokedexView(),
),
);
}
}
Well, the MultiBlocProvider has to be the main parent that is going to provide for the whole MaterialApp, not be a child of it, I mean ? That's why the problem was asking for a Bloc provider, but I
it couldn't find one.
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MultiBlocProvider( // change here
providers: [
BlocProvider<PokemonBloc>(
create: (context) =>
PokemonBloc()..add(const PokemonPageRequestEvent(page: 0))),
BlocProvider<PokemonDetailsBloc>(
create: (context) => PokemonDetailsBloc()),
],
child: MaterialApp(
title: 'Material App',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.red,
),
home: const PokedexView(),
),
);
}
}