app/lib/models/label.dart
2019-03-16 20:56:20 +01:00

38 lines
1014 B
Dart

import 'package:meta/meta.dart';
import 'package:vikunja_app/models/user.dart';
class Label {
final int id;
final String title, description, hexColor;
final DateTime created, updated;
final User createdBy;
Label(
{@required this.id,
this.title,
this.description,
this.hexColor,
this.created,
this.updated,
this.createdBy});
Label.fromJson(Map<String, dynamic> json)
: id = json['id'],
title = json['title'],
description = json['description'],
hexColor = json['hex_color'],
updated = DateTime.fromMillisecondsSinceEpoch(json['updated']),
created = DateTime.fromMillisecondsSinceEpoch(json['created']),
createdBy = User.fromJson(json['created_by']);
toJSON() => {
'id': id,
'title': title,
'description': description,
'hex_color': description,
'created_by': createdBy?.toJSON(),
'updated': updated?.millisecondsSinceEpoch,
'created': created?.millisecondsSinceEpoch,
};
}