I\'m having trouble trying to access an InheritedWidget after navigating to a new widget.
I have my top level widget like this
class App extends Statele
In the code you've provided, LoginScreen
is not a descendant of LoginBlocProvider
which is why it can't find the ancestor widget. Your code wraps the WelcomeScreen
route in LoginBlocProvider
, but not the whole navigator. The solution is to wrap your MaterialApp
in LoginBlocProvider
and then you will have access to it everywhere in your app.
class App extends StatelessWidget {
@override
Widget build(context) {
return LoginBlocProvider(
child: MaterialApp(
title: 'Iniciar Sesion',
home: WelcomeScreen(),
),
);
}
}