0

I am trying to update some property in flutter redux but i am getting the following error

Class 'DivMatches' has no instance setter 'id='.

Here is my state class

class AppState {
  var demoState;
  List myMatches;

  AppState({this.demoState, this.myMatches});

  AppState copywith({demoState, myMatches}){
  return AppState(
     myMatches : myMatches ?? this.myMatches,
     demoState: demoState ?? this.demoState,
  );

 }
}

My action looks like this

class UpdateDivResult{ // update the div result by id
  dynamic id;
  UpdateDivResult(this.id);
 }

My reducer looks like this

   var newMatch = state.myMatches[0][0];
    newMatch.id = 223;

    return state.copywith(
       myMatches: newMatch
    );

Please help. Thank you so much.

Hkm Sadek
  • 2,987
  • 9
  • 43
  • 95

1 Answers1

1

The problem was, I made my variables final in json serializeble. removing final will allow you to update.

Hkm Sadek
  • 2,987
  • 9
  • 43
  • 95