我的集团面临一个问题。在应用程序中,用户可以按多个值进行过滤。当我使用时filter
,转换正确完成,但是当我使用时filter2
,什么都没有发生,并且状态没有重建BlocBuilder
。我错过了什么吗?这两种方法(一种有效,另一种无效)有什么区别?
示例方法:
Stream<EventFilteredState> _mapUpdateFilterToState(
UpdateFilter event,
) async* {
if (eventsBloc.state is EventsLoaded) {
final events = (eventsBloc.state as EventsLoaded).events;
final filter = [event.faculty]..addAll((state as FilteredEventsLoaded).faculties);
final filter2 = (state as FilteredEventsLoaded).faculties..add(event.faculty);
yield FilteredEventsLoaded(events, filter);
}
}