Hkm Sadek
Hkm Sadek

Reputation: 3209

Class has no instance setter 'id='

In dart, I am getting this error while trying to override a property like this

var newId = state.myMatches[0][0].id = 90;

I am getting this error

flutter: The following NoSuchMethodError was thrown while handling a gesture:
flutter: Class 'DivMatches' has no instance setter 'id='.
flutter: Receiver: Instance of 'DivMatches'
flutter: Tried calling: id=90

There is no properties that private. All are public. Any help what's happening?

Thank you.

Upvotes: 3

Views: 2170

Answers (2)

Wesley Barnes
Wesley Barnes

Reputation: 671

Not sure of your setup, but if anyone else is getting this, I removed "final" from my mapping setup variable, and it worked.

Upvotes: 3

lrn
lrn

Reputation: 71653

You are looking up state.myMatches[0][0], which is apparently an instance of DivMatches. Then you try to assign 90 to the id property of that object, but DivMatches does not have any id setter, so the assignment fails with a NoSuchMethodError.

Upvotes: 1

Related Questions