小编Vin*_*ois的帖子

Flutter Bloc:从上下文开始找不到祖先?

我是 Flutter 的新手,也是 Bloc 的新手。

编译代码时出现错误:

    The following assertion was thrown building Login(dirty, state: _LoginFormState#44e7f):
         BlocProvider.of() called with a context that does not contain a Bloc of type BtnBloc.
         No ancestor could be found starting from the context that was passed to
         BlocProvider.of<BtnBloc>().
       This can happen if the context you use comes from a widget above the BlocProvider.
         This can also happen if you used BlocProviderTree and didn't explicity provide 
         the BlocProvider types: BlocProvider(bloc: BtnBloc()) instead of BlocProvider<BtnBloc>(bloc:
         BtnBloc()).
         The …
Run Code Online (Sandbox Code Playgroud)

flutter

6
推荐指数
2
解决办法
4596
查看次数

标签 统计

flutter ×1