SpinnerEntity.fromJson constructor

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

Implementation

factory SpinnerEntity.fromJson(Map<String, dynamic> json) {
  var entity = SpinnerEntity(key: '${json["key"] ?? 'keyName'}');
  // if (json["key"] is String) {
  //   key = json["key"];
  // }

  entity = entity.copyWith(extraData: json["extraData"]);

  if (json["isRadio"] is bool) {
    entity = entity.copyWith(isRadio: json["isRadio"]);
  }
  if (json["title"] is String) {
    entity = entity.copyWith(title: json["title"]);
  }
  if (json["type"] is MoreContentType) {
    entity = entity.copyWith(type: json["type"]);
  }
  if (json["desc"] is String) {
    entity = entity.copyWith(desc: json["desc"]);
  }
  if (json["titleSuffix"] is String) {
    entity = entity.copyWith(titleSuffix: json["titleSuffix"]);
  }
  if (json["items"] is List) {
    entity = entity.copyWith(
        items: json["items"] == null
            ? []
            : (json["items"] as List)
                .map((e) => SpinnerItemData.fromJson(e))
                .toList());
  }
  return entity;
}