Ошибка: I / flutter (5919): ══╡ ИСКЛЮЧЕНИЕ, ЗАЯВЛЕННОЕ БИБЛИОТЕКОЙ ВИДЖЕТОВ ╞═════════════════════════════════════════════ ══════════════════════════ I / flutter (5919): Следующее утверждение было брошено Building Builder: I / flutter (5919): BlocProvider .of () вызывается с контекстом, который не содержит Bloc типа Bloc. I / flutter (5919): не удалось найти предка, начиная с контекста, который был передан в I / flutter (5919): BlocProvider.of> (). I / flutter (5919):
Это может произойти, если используемый вами контекст исходит из виджета над BlocProvider. I / flutter (5919): использовался контекст: BlocBuilder, dynamic> (dirty, state: I / flutter (5919): _BlocBuilderBaseState, dynamic> # 55a7d (состояние жизненного цикла: создано)) I / flutter (5919): соответствующий виджет, вызывающий ошибку: I / flutter (5919): MaterialApp /lib/main.dart:35:12
Вот мой главный
void main() {
final StorageRepository storageRepository = StorageRepository();
final AuthenticationRepository authenticationRepository =
AuthenticationRepository();
runApp(BlocProvider<AuthenticationBloc>(
create: (_) => AuthenticationBloc(
authenticationRepository: authenticationRepository,
storageRepository: storageRepository),
child: MyApp()));
}
Виджет MaterialApp
MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.deepPurple),
home: BlocBuilder(
builder: (context, state) {
print(state);
if (state is Authenticated) {
return MainPage();
} else if (state is Unauthenticated) {
return LoginPage();
} else if (state is Uninitialized) {
return SplashScreen();
}
return Container();
},
),