Overrode [hasCode] and the [==] operator for all model classes
This commit is contained in:
parent
376557e35e
commit
156af9124c
5 changed files with 104 additions and 8 deletions
|
|
@ -46,4 +46,31 @@ class EventModel {
|
|||
"lowPriority": lowPriority,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
id.hashCode ^
|
||||
name.hashCode ^
|
||||
pendigTasks.hashCode ^
|
||||
when.hashCode ^
|
||||
media.hashCode ^
|
||||
tasks.hashCode ^
|
||||
highPriority.hashCode ^
|
||||
mediumPriority.hashCode ^
|
||||
lowPriority.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is EventModel &&
|
||||
runtimeType == other.runtimeType &&
|
||||
id == other.id &&
|
||||
name == other.name &&
|
||||
pendigTasks == other.pendigTasks &&
|
||||
when == other.when &&
|
||||
media == other.media &&
|
||||
tasks == other.tasks &&
|
||||
highPriority == other.highPriority &&
|
||||
mediumPriority == other.mediumPriority &&
|
||||
lowPriority == other.lowPriority;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,4 +54,33 @@ class SummaryModel {
|
|||
"addedFriday": addedFriday,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
completedMonday.hashCode ^
|
||||
addedMonday.hashCode ^
|
||||
completedTuesday.hashCode ^
|
||||
addedTuesday.hashCode ^
|
||||
completedWednesday.hashCode ^
|
||||
addedWednesday.hashCode ^
|
||||
completedThursday.hashCode ^
|
||||
addedThursday.hashCode ^
|
||||
completedFriday.hashCode ^
|
||||
addedFriday.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is SummaryModel &&
|
||||
runtimeType == other.runtimeType &&
|
||||
completedMonday == other.completedMonday &&
|
||||
addedMonday == other.addedMonday &&
|
||||
completedTuesday == other.completedTuesday &&
|
||||
addedTuesday == other.addedTuesday &&
|
||||
completedWednesday == other.completedWednesday &&
|
||||
addedWednesday == other.addedWednesday &&
|
||||
completedThursday == other.completedThursday &&
|
||||
addedThursday == other.addedThursday &&
|
||||
completedFriday == other.completedFriday &&
|
||||
addedFriday == other.addedFriday;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,4 +34,25 @@ class TaskModel {
|
|||
"event": event,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
id.hashCode ^
|
||||
text.hashCode ^
|
||||
priority.hashCode ^
|
||||
ownerUsername.hashCode ^
|
||||
done.hashCode ^
|
||||
event.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
runtimeType == other.runtimeType &&
|
||||
other is TaskModel &&
|
||||
id == other.id &&
|
||||
text == other.text &&
|
||||
priority == other.priority &&
|
||||
ownerUsername == other.ownerUsername &&
|
||||
done == other.done &&
|
||||
event == other.event;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,14 +22,7 @@ class UserModel {
|
|||
this.pendingHigh,
|
||||
this.pendingMedium,
|
||||
this.pendingLow,
|
||||
}) : assert(id != null),
|
||||
assert(username != null),
|
||||
assert(tasks != null),
|
||||
assert(summary != null),
|
||||
assert(userId != null),
|
||||
assert(pendingHigh != null),
|
||||
assert(pendingMedium != null),
|
||||
assert(pendingLow != null);
|
||||
});
|
||||
|
||||
///Returns a [UserModel] from a map.
|
||||
UserModel.fromFirestore(Map<String, dynamic> firestoreMap, {String id})
|
||||
|
|
@ -42,4 +35,29 @@ class UserModel {
|
|||
pendingHigh = firestoreMap["pendingHigh"],
|
||||
pendingMedium = firestoreMap["pendingMedium"],
|
||||
pendingLow = firestoreMap["pendingLow"];
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
id.hashCode ^
|
||||
username.hashCode ^
|
||||
tasks.hashCode ^
|
||||
summary.hashCode ^
|
||||
userId.hashCode ^
|
||||
pendingHigh.hashCode ^
|
||||
pendingMedium.hashCode ^
|
||||
pendingLow.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
runtimeType == other.runtimeType &&
|
||||
other is UserModel &&
|
||||
id == other.id &&
|
||||
username == other.username &&
|
||||
tasks == other.tasks &&
|
||||
summary == other.summary &&
|
||||
userId == other.userId &&
|
||||
pendingHigh == other.pendingHigh &&
|
||||
pendingMedium == other.pendingMedium &&
|
||||
pendingLow == other.pendingLow;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ dependencies:
|
|||
http: ^0.12.0
|
||||
sqflite: ^1.1.0
|
||||
rxdart: ^0.20.0
|
||||
mockito: ^4.0.0
|
||||
firebase_core: ^0.3.0
|
||||
firebase_analytics: ^2.0.2
|
||||
cloud_firestore: ^0.9.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue