CPD_2024_todo/lib/models/todo.dart

35 lines
767 B
Dart

class ToDo {
String title;
String? description;
DateTime deadline;
String priority;
bool isCompleted;
ToDo({
required this.title,
required this.description,
required this.deadline,
required this.priority,
this.isCompleted = false,
});
Map<String, dynamic> toJson() {
return {
'title': title,
'description': description,
'deadline': deadline.toIso8601String(),
'priority': priority,
'isCompleted': isCompleted,
};
}
static ToDo fromJson(Map<String, dynamic> json) {
return ToDo(
title: json['title'],
description: json['description'],
deadline: DateTime.parse(json['deadline']),
priority: json['priority'],
isCompleted: json['isCompleted'],
);
}
}