46 lines
1.2 KiB
Dart
46 lines
1.2 KiB
Dart
class ScheduleItem {
|
|
final String id;
|
|
final String title;
|
|
final String description;
|
|
final DateTime startDate;
|
|
final DateTime endDate;
|
|
final String familyMemberId;
|
|
final bool isAllDay;
|
|
|
|
const ScheduleItem({
|
|
required this.id,
|
|
required this.title,
|
|
required this.description,
|
|
required this.startDate,
|
|
required this.endDate,
|
|
required this.familyMemberId,
|
|
required this.isAllDay,
|
|
});
|
|
|
|
factory ScheduleItem.fromJson(Map<String, dynamic> json) {
|
|
return ScheduleItem(
|
|
id: json["_id"] as String? ?? "",
|
|
title: json["title"] as String? ?? "",
|
|
description: json["description"] as String? ?? "",
|
|
startDate:
|
|
DateTime.tryParse(json["startDate"] as String? ?? "") ??
|
|
DateTime.now(),
|
|
endDate:
|
|
DateTime.tryParse(json["endDate"] as String? ?? "") ?? DateTime.now(),
|
|
familyMemberId: json["familyMemberId"] as String? ?? "",
|
|
isAllDay: json["isAllDay"] as bool? ?? false,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
"title": title,
|
|
"description": description,
|
|
"startDate": startDate.toIso8601String(),
|
|
"endDate": endDate.toIso8601String(),
|
|
"familyMemberId": familyMemberId,
|
|
"isAllDay": isAllDay,
|
|
};
|
|
}
|
|
}
|