when i add or remove item from i want to update widget based on state but state not updating but if i use a extra variable bool isChangeInList for update list it’s working
and when i emit like below it’s working fine
how to update list changes in ui without extra variable
cubit.dart
if(state.selectedFilterCategories.contains(categoryId)){
state.selectedFilterCategories.remove(categoryId);
}else{
state.selectedFilterCategories.add(categoryId);
}
emit(state.copyWith(selectedFilterCategories:List.of(state.selectedFilterCategories)));
}
cubit_state.dart
@Freezed(makeCollectionsUnmodifiable: false)
class OfferState with _$OfferState {
factory OfferState.initial({
required List<int> selectedFilterCategories,
}) = _Initial;
}