mirror of
https://github.com/go-vikunja/app
synced 2024-06-03 19:19:46 +00:00
056b2d72c9
This PR formats all code with dart format and adds a step to the CI so that it will be checked on every push and PR.
54 lines
1.5 KiB
Dart
54 lines
1.5 KiB
Dart
import 'package:vikunja_app/models/task.dart';
|
|
import 'package:vikunja_app/models/user.dart';
|
|
|
|
class TaskList {
|
|
final int id;
|
|
int namespaceId;
|
|
String title, description;
|
|
final User owner;
|
|
final DateTime created, updated;
|
|
final List<Task> tasks;
|
|
final bool isFavorite;
|
|
|
|
TaskList({
|
|
this.id = 0,
|
|
required this.title,
|
|
required this.namespaceId,
|
|
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 ?? [];
|
|
|
|
TaskList.fromJson(Map<String, dynamic> json)
|
|
: id = json['id'],
|
|
owner = User.fromJson(json['owner']),
|
|
description = json['description'],
|
|
title = json['title'],
|
|
updated = DateTime.parse(json['updated']),
|
|
created = DateTime.parse(json['created']),
|
|
isFavorite = json['is_favorite'],
|
|
namespaceId = json['namespace_id'],
|
|
tasks = json['tasks'] == null
|
|
? []
|
|
: (json['tasks'] as List<dynamic>)
|
|
.map((taskJson) => Task.fromJson(taskJson))
|
|
.toList();
|
|
|
|
toJSON() {
|
|
return {
|
|
'id': id,
|
|
'title': title,
|
|
'description': description,
|
|
'owner': owner.toJSON(),
|
|
'created': created.toUtc().toIso8601String(),
|
|
'updated': updated.toUtc().toIso8601String(),
|
|
'namespace_id': namespaceId
|
|
};
|
|
}
|
|
}
|