I have wrapped the MaterialApp with a BlocProvider / BlocListener
I get an error
"Unhandled Exception: 'package:go_router/src/router.dart': Failed assertion: line 280 pos 12: 'inherited != null': No GoRouter found in context" from the Listener callback
Widget build(BuildContext context) {
return BlocProvider<AuthenticationBloc>(
create: (context) => AuthenticationBloc()..add(AppStarted()),
child: BlocListener<AuthenticationBloc, AuthenticationState>(
listener: (context, state) {
if (state is AuthenticationUnauthenticated) {
context.goNamed(LoginPage.routeName);
}
if (state is AuthenticationAuthenticated) {
context.goNamed(NavigationBarContainer.routeName);
}
},
child: MaterialApp.router(
title: 'Flutter Demo',
routeInformationProvider: _router.routeInformationProvider,
routeInformationParser: _router.routeInformationParser,
routerDelegate: _router.routerDelegate,
theme: ThemeData(
primarySwatch: Colors.blue,
)),
),
);
}
MaterialApp.builder
, which I have done, but I still have the same error. – Indeterminism