为什么会出现这个错误?:
Error: The superclass, 'Bloc', has no unnamed constructor that takes no arguments.
class OverViewListBloc extends Bloc<OListEvent, List<OList>> {
我可以用 修复它OverViewListBloc(List<OList> initialState) : super(initialState);
,但我不想这样修复它,因为我必须给出一个论点。
这是我的代码:
class OverViewListBloc extends Bloc<OListEvent, List<OList>> {
OverViewListBloc(List<OList> initialState) : super(initialState);
List<OList> get initialState => List<OList>();
@override
Stream<List<OList>> mapEventToState(OListEvent event) async* {
if (event is SetList) {
yield event.foodList;
} else if (event is AddList) {
List<OList> newState = List.from(state);
if (event.newolist != null) {
newState.add(event.newolist);
}
yield newState;
} else if (event is DeleteList) {
List<OList> newState = List.from(state);
newState.removeAt(event.olistindex);
yield newState;
} else if (event is UpdateList) {
List<OList> newState = List.from(state);
newState[event.listIndex] = event.newolist;
yield newState;
}
}
}
还有其他修复吗?