1
0
mirror of https://github.com/go-vikunja/app synced 2024-06-01 10:16:53 +00:00
app-mirror-github/lib/models/list.dart

54 lines
1.5 KiB
Dart
Raw Normal View History

2019-03-11 20:29:15 +00:00
import 'package:vikunja_app/models/task.dart';
import 'package:vikunja_app/models/user.dart';
class TaskList {
final int id;
2022-08-26 15:38:32 +00:00
int namespaceId;
2022-09-03 15:43:16 +00:00
String title, description;
final User owner;
final DateTime created, updated;
final List<Task> tasks;
2022-04-12 21:27:14 +00:00
final bool isFavorite;
2019-03-11 20:29:15 +00:00
TaskList({
2022-09-07 18:22:42 +00:00
this.id = 0,
required this.title,
required this.namespaceId,
2022-09-03 15:43:16 +00:00
this.description = '',
required this.owner,
DateTime? created,
DateTime? updated,
List<Task>? tasks,
this.isFavorite = false,
}) : this.created = created ?? DateTime.now(),
this.updated = updated ?? DateTime.now(),
this.tasks = tasks ?? [];
2019-03-11 20:29:15 +00:00
TaskList.fromJson(Map<String, dynamic> json)
: id = json['id'],
2022-09-03 15:43:16 +00:00
owner = User.fromJson(json['owner']),
2019-03-11 20:29:15 +00:00
description = json['description'],
title = json['title'],
2020-04-27 15:02:55 +00:00
updated = DateTime.parse(json['updated']),
created = DateTime.parse(json['created']),
2022-04-12 21:27:14 +00:00
isFavorite = json['is_favorite'],
2022-08-26 15:38:32 +00:00
namespaceId = json['namespace_id'],
tasks = json['tasks'] == null
? []
: (json['tasks'] as List<dynamic>)
.map((taskJson) => Task.fromJson(taskJson))
.toList();
2019-03-11 20:29:15 +00:00
toJSON() {
return {
2022-09-07 18:22:42 +00:00
'id': id,
2022-09-03 15:43:16 +00:00
'title': title,
'description': description,
'owner': owner.toJSON(),
'created': created.toUtc().toIso8601String(),
'updated': updated.toUtc().toIso8601String(),
2022-09-03 15:43:16 +00:00
'namespace_id': namespaceId
2019-03-11 20:29:15 +00:00
};
}
}