【发布时间】:2020-04-30 13:52:33
【问题描述】:
@override
Widget build(BuildContext context) {
return BlocProvider<HomeBloc>(
create: (context) {
return HomeBloc(homeRepo: HomeRepository());
},
child: BlocProvider.of<HomeBloc>(context).state is HomeStateLoading
? CircularProgressIndicator()
: Container());
}
我对错误感到困惑:
BlocProvider.of() called with a context that does not contain a Bloc of type HomeBloc.
No ancestor could be found starting from the context that was passed to
BlocProvider.of<HomeBloc>().
我不是刚刚在其直接父级创建了HomeBloc 吗?它想要什么?
【问题讨论】:
标签: flutter dart provider bloc