TetraStats/lib/data_objects/badge.dart

35 lines
806 B
Dart
Raw Normal View History

2024-09-05 21:42:21 +00:00
// 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;
}