35 lines
806 B
Dart
35 lines
806 B
Dart
// ignore_for_file: hash_and_equals
|
|
|
|
class Badge {
|
|
late String badgeId;
|
|
late String label;
|
|
DateTime? ts;
|
|
|
|
Badge({required this.badgeId, required this.label, this.ts});
|
|
|
|
Badge.fromJson(Map<String, dynamic> json) {
|
|
badgeId = json['id'];
|
|
label = json['label'];
|
|
ts = (json['ts'] != null && json['ts'] is String) ? DateTime.parse(json['ts']) : null; // man i love osk
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['id'] = badgeId;
|
|
data['label'] = label;
|
|
data['ts'] = ts?.toString();
|
|
return data;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return "Badge $label ($badgeId)";
|
|
}
|
|
|
|
@override
|
|
int get hashCode => badgeId.hashCode;
|
|
|
|
@override
|
|
bool operator ==(covariant Badge other) => badgeId == other.badgeId;
|
|
}
|