Flutter Bloc:Bloc事件:Equatable:类只能扩展其他类
在 Flutter 中使用 Bloc。 在 Bloc 活动中,我遇到了一个关于 Equatable 的问题。 首先,我无法导入 equatable
包: import 'package:equatable/equatable.dart';错误说: “part-of 指令必须是部件中的唯一指令。尝试删除其他指令,或将它们移至该部件所属的库”。
后来,当我创建事件并扩展 Equatable 时,错误提示: “类只能扩展其他类。尝试指定不同的超类,或删除扩展子句”。
(仅供参考:我将公平依赖项放入 pubspec.yaml
中)。
我将一如既往地感谢您的帮助!
Playing around with Bloc in Flutter.
In the Bloc event, I faced a problem regarding Equatable.
At first, I cannot import equatable
package: import 'package:equatable/equatable.dart'; The error says:
"The part-of directive must be the only directive in a part. Try removing other directives, or moving them to the library for which this is a part".
Later on, when I create the Event and extends Equatable, the error says:
"Classes can only extend other classes. Try specifying a different superclass, or removing the extends clause".
(FYI: I put into the pubspec.yaml
the equitable dependency).
I will appreciate your assistance, as always!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该错误消息意味着您无法从 bloc_event.dart 导入任何包,因为 bloc_event.dart 是 bloc_bloc.dart 的一部分。尝试在bloc_bloc.dart中导入equatable包。并且不要忘记flutter pub get。
That error message means you can't import any package from bloc_event.dart because bloc_event.dart is part of bloc_bloc.dart. Try to import the equatable package in bloc_bloc.dart. And don't forget to flutter pub get.
它返回错误,因为
bloc_event.dart
是bloc_bloc.dart
的一部分。尝试:
bloc_bloc.dart
中导入 equatable 包,It's returning an error because
bloc_event.dart
is part ofbloc_bloc.dart
.Try to:
bloc_bloc.dart