I am facing an issue in my Bloc. In the app, user can filter by multiple values. When I use filter
, transition is done correctly, but when I used filter2
, nothing is happening and state is not rebuilt in BlocBuilder
. Am I missing something? What is the difference between these two approaches (one working and another not)?
Example method:
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);
}
}