CPD_2024_todo/lib/models/todo.dart

35 lines
767 B
Dart
Raw Permalink Normal View History

2024-10-22 20:42:08 +02:00
class ToDo {
String title;
String? description;
DateTime deadline;
String priority;
2024-10-22 20:42:08 +02:00
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'],
);
}
}