cpd_2024_todo/lib/buisness/ToDoItem.dart

35 lines
698 B
Dart
Raw Normal View History

2024-10-22 10:38:22 +02:00
class ToDoItem {
2024-10-29 13:13:10 +01:00
int? id;
2024-10-22 10:38:22 +02:00
String name;
String description;
DateTime dueDate;
String status;
ToDoItem({
2024-10-29 13:13:10 +01:00
this.id,
2024-10-22 10:38:22 +02:00
required this.name,
required this.description,
required this.dueDate,
this.status = 'Pending',
});
2024-10-29 13:13:10 +01:00
Map<String, dynamic> toMap() {
2024-10-22 10:38:22 +02:00
return {
2024-10-29 13:13:10 +01:00
'id' : id,
2024-10-22 10:38:22 +02:00
'name': name,
'description': description,
'dueDate': dueDate.toIso8601String(),
'status': status,
};
}
2024-10-29 13:13:10 +01:00
static ToDoItem fromMap(Map<String, dynamic> json) {
2024-10-22 10:38:22 +02:00
return ToDoItem(
2024-10-29 13:13:10 +01:00
id: json['id'],
2024-10-22 10:38:22 +02:00
name: json['name'],
description: json['description'],
dueDate: DateTime.parse(json['dueDate']),
status: json['status'],
);
}
}