Is that logical? Object equals but element not equals.
FantaZZ opened this issue · 1 comments
FantaZZ commented
import 'package:equatable/equatable.dart';
class Person extends Equatable {
final String name;
final List<Card> cards;
const Person({
required this.name,
required this.cards,
});
@override
List<Object> get props => [name, cards];
}
// ** not @immutable **
class Card extends Equatable {
String name;
Card({
required this.name,
});
@override
List<Object> get props => [name];
}
main() {
List<Card> cards = [Card(name: 'visa')];
Person jax = Person(name: 'jax', cards: cards);
List<Card> cardsCopy = [...cards];
cardsCopy[0].name = 'mastercard';
Person jaxCopy = Person(name: 'jax', cards: cardsCopy);
print(cards == cardsCopy); // false
print(jax == jaxCopy); // true
}
FantaZZ commented
Oh I got point