Initial commit
This commit is contained in:
36
flutter_app/lib/models/todo_item.dart
Normal file
36
flutter_app/lib/models/todo_item.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
class TodoItem {
|
||||
final String id;
|
||||
final String familyMemberId;
|
||||
final String title;
|
||||
final bool completed;
|
||||
final DateTime? dueDate;
|
||||
|
||||
const TodoItem({
|
||||
required this.id,
|
||||
required this.familyMemberId,
|
||||
required this.title,
|
||||
required this.completed,
|
||||
required this.dueDate,
|
||||
});
|
||||
|
||||
factory TodoItem.fromJson(Map<String, dynamic> json) {
|
||||
return TodoItem(
|
||||
id: json["_id"] as String? ?? "",
|
||||
familyMemberId: json["familyMemberId"] as String? ?? "",
|
||||
title: json["title"] as String? ?? "",
|
||||
completed: json["completed"] as bool? ?? false,
|
||||
dueDate: json["dueDate"] != null
|
||||
? DateTime.tryParse(json["dueDate"] as String)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"familyMemberId": familyMemberId,
|
||||
"title": title,
|
||||
"completed": completed,
|
||||
"dueDate": dueDate?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user