fromJson static method

TaskPatch? fromJson(
  1. Map<String, dynamic>? json
)

Returns a new TaskPatch instance and imports its values from json if it's non-null, null if json is null.

Implementation

static TaskPatch? fromJson(Map<String, dynamic>? json) {
  if (json == null) {
    return null;
  }

  DateTime? dueBy =
      json[r'dueBy'] == null ? null : DateTime.parse(json[r'dueBy']);
  if (dueBy != null && dueBy.isUtc == false) {
    dueBy = DateTime.parse('${json[r'dueBy']}Z');
  }

  DateTime? scheduledAt = json[r'scheduledAt'] == null
      ? null
      : DateTime.parse(json[r'scheduledAt']);
  if (scheduledAt != null && scheduledAt.isUtc == false) {
    scheduledAt = DateTime.parse('${json[r'scheduledAt']}Z');
  }

  return TaskPatch(
    archivedAt: json[r'archivedAt'],
    category: json[r'category'],
    description: json[r'description'],
    dueBy: dueBy,
    identificationNumber: json[r'identificationNumber'],
    name: json[r'name'],
    priority: json[r'priority'],
    scheduledAt: scheduledAt,
    tags: json[r'tags'] == null ? null : List<String>.from(json[r'tags']),
  );
}