[英]error: The setter 'observer' isn't defined for the type 'Bloc<Event, State>'
I'm using flutter_bloc and according to this example I want to observe the bloc.我正在使用 flutter_bloc,根据这个例子,我想观察这个集团。 but I get this error:
但我收到此错误:
error: The setter 'observer' isn't defined for the type 'Bloc<Event, State>'. (undefined_setter at [login_bloc_project] lib\main.dart:12)
when calling this method:调用此方法时:
void main() {
Bloc.observer = MyBlocObserver();
runApp(MyApp());
}
how can I fix this error?我该如何解决这个错误?
You can try like this:你可以这样尝试:
BlocOverrides.runZoned(
() => runApp(const MyApp()),
blocObserver: MyBlocObserver(),
);
Your package version might be lower than v8.1.0.您的软件包版本可能低于 v8.1.0。 BlocObserver is updated with that version.
BlocObserver 已更新为该版本。 You can upgrade your dependency to solve this.
你可以升级你的依赖来解决这个问题。
For more info: https://bloclibrary.dev/#/migration?id=v810更多信息: https ://bloclibrary.dev/#/migration?id=v810
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.