Added copyWith(), == and hashCode overwrites for model classes

This commit is contained in:
2026-05-01 17:22:20 +02:00
parent cbc8a1afce
commit ae3a8b496e
7 changed files with 215 additions and 14 deletions

View File

@@ -10,6 +10,26 @@ class ScoreEntry {
return 'ScoreEntry{roundNumber: $roundNumber, score: $score, change: $change}';
}
ScoreEntry copyWith({int? roundNumber, int? score, int? change}) {
return ScoreEntry(
roundNumber: roundNumber ?? this.roundNumber,
score: score ?? this.score,
change: change ?? this.change,
);
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ScoreEntry &&
runtimeType == other.runtimeType &&
roundNumber == other.roundNumber &&
score == other.score &&
change == other.change;
@override
int get hashCode => Object.hash(roundNumber, score, change);
ScoreEntry.fromJson(Map<String, dynamic> json)
: roundNumber = json['roundNumber'],
score = json['score'],