fromJson static method

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

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

Implementation

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

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

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

  return Template(
    body: json[r'body'] == null
        ? null
        : List<Map<String, dynamic>>.from(json[r'body']),
    createdAt: createdAt,
    footer: json[r'footer'] == null
        ? null
        : List<Map<String, dynamic>>.from(json[r'footer']),
    header: json[r'header'] == null
        ? null
        : List<Map<String, dynamic>>.from(json[r'header']),
    id: json[r'id'],
    name: json[r'name'],
    type: json[r'type'],
    updatedAt: updatedAt,
  );
}