added alarms to task model

This commit is contained in:
2026-07-20 13:39:26 +02:00
parent 7fed7bfe16
commit 79cae9570d
3 changed files with 18 additions and 2 deletions
+11 -1
View File
@@ -1,3 +1,4 @@
import 'alarm/alarm.dart';
import 'location.dart';
class Task {
@@ -10,6 +11,7 @@ class Task {
final String category;
final List<Task> subtasks;
final String url;
final List<Alarm> alarms;
Task({
required this.id,
@@ -21,6 +23,7 @@ class Task {
this.category = '',
this.subtasks = const [],
this.url = '',
required this.alarms,
});
Task copyWith({
@@ -32,7 +35,7 @@ class Task {
bool? isCompleted,
String? category,
List<Task>? subtasks,
List<DateTime>? alarms,
List<Alarm>? alarms,
Location? location,
String? url,
}) {
@@ -46,6 +49,7 @@ class Task {
category: category ?? this.category,
subtasks: subtasks ?? this.subtasks,
url: url ?? this.url,
alarms: alarms ?? this.alarms,
);
}
@@ -66,6 +70,11 @@ class Task {
.toList() ??
[],
url: json['url'] as String? ?? '',
alarms:
(json['alarms'] as List<dynamic>?)
?.map((e) => Alarm.fromJson(e as Map<String, dynamic>))
.toList() ??
[],
);
}
@@ -80,6 +89,7 @@ class Task {
'category': category,
'subtasks': subtasks.map((e) => e.toJson()).toList(),
'url': url,
'alarms': alarms.map((e) => e.toJson()).toList(),
};
}