Added copyWith(), == and hashCode overwrites for model classes
This commit is contained in:
@@ -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'],
|
||||
|
||||
Reference in New Issue
Block a user