cpd_2024_todo/lib/buisness/ToDoItem.dart

34 lines
713 B
Dart
Raw Normal View History

2024-10-22 10:38:22 +02:00
class ToDoItem {
String name;
String description;
DateTime dueDate;
String status;
ToDoItem({
required this.name,
required this.description,
required this.dueDate,
this.status = 'Pending',
});
// Convert ToDoItem to JSON format
Map<String, dynamic> toJson() {
return {
'name': name,
'description': description,
'dueDate': dueDate.toIso8601String(),
'status': status,
};
}
// Create ToDoItem from JSON format
static ToDoItem fromJson(Map<String, dynamic> json) {
return ToDoItem(
name: json['name'],
description: json['description'],
dueDate: DateTime.parse(json['dueDate']),
status: json['status'],
);
}
}