34 lines
713 B
Dart
34 lines
713 B
Dart
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'],
|
|
);
|
|
}
|
|
}
|