CocLayout.fromJson constructor

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

Implementation

factory CocLayout.fromJson(Map<String, dynamic>? json) {
  if (json == null) return CocLayout();

  return CocLayout(
    id: json['id'] as int?,
    townHall: json['town_hall'] as int?,
    layoutType: json['layout_type'] as String?,
    subTypes: json['sub_types'] != null
        ? List<String>.from(jsonDecode(json['sub_types']))
        : null,
    title: json['title'] as String?,
    image: json['image'] as String?,
    detailUrl: json['detail_url'] as String?,
    baseLink: json['base_link'] as String?,
    views: json['views'] as int?,
    source: json['source'] as String?,
    baseType: json['base_type'] as String?,
    createdAt: json['created_at'] != null
        ? DateTime.tryParse(json['created_at'])
        : null,
    updatedAt: json['updated_at'] != null
        ? DateTime.tryParse(json['updated_at'])
        : null,
  );
}