Initial commit
This commit is contained in:
45
flutter_app/lib/models/schedule_item.dart
Normal file
45
flutter_app/lib/models/schedule_item.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user