I'm building a basic Flutter app with Bloc pattern. This is my structure so far.
MainProvider
contains the Repository
, which I can pass in every Bloc
of every sub page (one Bloc per page, basically).
The problem is that, if I want to access MainProvider
like this:
final provider = MainProvider.of(context);
from MenuPage, or OtherPage, which I access to by navigating from HomePage with
Navigator.push(context,
MaterialRoutePage(
(context) => MenuPage(homePageParam); //or OtherPage(homePageParam)
);
the .of
method returns null
.
How can I properly access that InheritedWidget
? Should I do another type of Navigator.push
?