Updated the model
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
75f6608863
commit
9606fe4ad6
|
@ -2,47 +2,70 @@ import 'package:vikunja_app/models/user.dart';
|
|||
import 'package:meta/meta.dart';
|
||||
|
||||
class Task {
|
||||
final int id;
|
||||
final DateTime created, updated, due;
|
||||
final List<DateTime> reminders;
|
||||
final int id, parentTaskID, priority;
|
||||
final DateTime created, updated, dueDate, startDate, endDate;
|
||||
final List<DateTime> reminderDates;
|
||||
final String text, description;
|
||||
final bool done;
|
||||
final User owner;
|
||||
final User createdBy;
|
||||
final Duration repeatAfter;
|
||||
final List<Task> subtasks;
|
||||
|
||||
//labels
|
||||
|
||||
Task(
|
||||
{@required this.id,
|
||||
this.text,
|
||||
this.description,
|
||||
this.done,
|
||||
this.reminderDates,
|
||||
this.dueDate,
|
||||
this.startDate,
|
||||
this.endDate,
|
||||
this.parentTaskID,
|
||||
this.priority,
|
||||
this.repeatAfter,
|
||||
this.subtasks,
|
||||
this.created,
|
||||
this.updated,
|
||||
this.reminders,
|
||||
this.due,
|
||||
@required this.text,
|
||||
this.description,
|
||||
@required this.done,
|
||||
@required this.owner});
|
||||
this.createdBy});
|
||||
|
||||
Task.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
updated = DateTime.fromMillisecondsSinceEpoch(json['updated']),
|
||||
created = DateTime.fromMillisecondsSinceEpoch(json['created']),
|
||||
reminders = (json['reminderDates'] as List<dynamic>)
|
||||
text = json['text'],
|
||||
description = json['description'],
|
||||
done = json['done'],
|
||||
reminderDates = (json['reminderDates'] as List<dynamic>)
|
||||
?.map((milli) => DateTime.fromMillisecondsSinceEpoch(milli))
|
||||
?.toList(),
|
||||
due = DateTime.fromMillisecondsSinceEpoch(json['dueDate']),
|
||||
description = json['description'],
|
||||
text = json['text'],
|
||||
done = json['done'],
|
||||
owner = User.fromJson(json['createdBy']);
|
||||
dueDate = DateTime.fromMillisecondsSinceEpoch(json['dueDate']),
|
||||
startDate = DateTime.fromMillisecondsSinceEpoch(json['startDate']),
|
||||
endDate = DateTime.fromMillisecondsSinceEpoch(json['endDate']),
|
||||
parentTaskID = json['parentTaskID'],
|
||||
priority = json['priority'],
|
||||
repeatAfter = Duration(seconds: json['repeatAfter']),
|
||||
subtasks = (json['subtasks'] as List<dynamic>)
|
||||
?.map((subtask) => Task.fromJson(subtask))
|
||||
?.toList(),
|
||||
updated = DateTime.fromMillisecondsSinceEpoch(json['updated']),
|
||||
created = DateTime.fromMillisecondsSinceEpoch(json['created']),
|
||||
createdBy = User.fromJson(json['createdBy']);
|
||||
|
||||
toJSON() => {
|
||||
'id': id,
|
||||
'text': text,
|
||||
'description': description,
|
||||
'done': done ?? false,
|
||||
'reminderDates':
|
||||
reminderDates?.map((date) => date.millisecondsSinceEpoch)?.toList(),
|
||||
'dueDate': dueDate?.millisecondsSinceEpoch,
|
||||
'startDate': startDate?.millisecondsSinceEpoch,
|
||||
'endDate': endDate?.millisecondsSinceEpoch,
|
||||
'priority': priority,
|
||||
'repeatAfter': repeatAfter.inSeconds,
|
||||
'subtasks': subtasks?.map((subtask) => subtask.toJSON())?.toList(),
|
||||
'createdBy': createdBy?.toJSON(),
|
||||
'updated': updated?.millisecondsSinceEpoch,
|
||||
'created': created?.millisecondsSinceEpoch,
|
||||
'reminderDates':
|
||||
reminders?.map((date) => date.millisecondsSinceEpoch)?.toList(),
|
||||
'dueDate': due?.millisecondsSinceEpoch,
|
||||
'description': description,
|
||||
'text': text,
|
||||
'done': done ?? false,
|
||||
'createdBy': owner?.toJSON()
|
||||
};
|
||||
}
|
||||
|
|
Reference in New Issue