Flutter Equatable Class properties must all be final Flutter Equatable Class properties must all be final dart dart

Flutter Equatable Class properties must all be final


See equatable docs:

Note: Equatable is designed to only work with immutable objects so all member variables must be final (This is not just a feature of Equatable - overriding a hashCode with a mutable value can break hash-based collections).

If you think about it, there is no reason that you'll have two mutable objects that have the same key, because if only one of them changes - the fact that they have comparable keys is meaningless.

You might just define a method in PriceItem that accepts another PriceItem and checks for key equality.


Use that way

class PriceItem extends Equatable {PriceItem({    this.key,  });  final String key;   @override  List<Object> get props => [        key,      ];}