I want to change List<Map<String, dynamic>> list on Bloc.
Below is my sample bloc code.
Please teach me how to use copyWith correctly.
[Sample Code]
class StateA extends Equatable {
List<Map<String, dynamic>> listMap;
StateA({ required this.listMap});
StateA copyWith(
{List<Map<String, dynamic>>? listMap,}) {
return StateA(
listMap: listMap ?? this.listMap);
}
}
class CubitA extends Cubit<StateA> {
CubitA() : super(StateA(listMap: []));
void testCopy() {
emit(state.copyWith(listMap: [{"test_key": "test_value"}]));
print(state.listMap); // => []
}
(I'm not good at English, sorry)