Task.fromJson constructor

Task.fromJson(
  1. Map<String, dynamic> json,
  2. String id
)

Implementation

factory Task.fromJson(Map<String, dynamic> json, String id) {
  final Timestamp? createdAt = json['createdAt'];
  final Timestamp? updatedAt = json['updatedAt'];
  final Timestamp? startAt = json['startAt'];
  final Timestamp? endAt = json['endAt'];

  return Task(
    id: id,
    title: json['title'],
    content: json['content'] ?? '',
    createdAt: createdAt == null ? DateTime.now() : createdAt.toDate(),
    updatedAt: updatedAt == null ? DateTime.now() : updatedAt.toDate(),
    startAt: startAt?.toDate(),
    endAt: endAt?.toDate(),
    assignTo: List<String>.from(json['assignTo'] ?? []),
  );
}