CivitaModel.fromJson constructor

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

Implementation

CivitaModel.fromJson(Map<String, dynamic> json) {
  id = json['id'];
  name = json['name'] ?? '';
  description = json['description'] ?? '';
  allowNoCredit = json['allowNoCredit'] ?? false;
  if (json['allowCommercialUse'] != null) {
    allowCommercialUse = json['allowCommercialUse'].cast<String>();
  } else {
    allowCommercialUse = [];
  }
  allowDerivatives = json['allowDerivatives'] ?? false;
  allowDifferentLicense = json['allowDifferentLicense'] ?? false;
  type = json['type'] ?? '';
  minor = json['minor'] ?? false;
  poi = json['poi'] ?? false;
  nsfw = json['nsfw'] ?? false;
  nsfwLevel = json['nsfwLevel'] ?? 0;
  if (json['tags'] != null) {
    tags = json['tags'].cast<String>();
  } else {
    tags = [];
  }
  mode = json['mode'] ?? '';
  if (json['creator'] != null) {
    creator = CivitaCreator.fromJson(json['creator']);
  }
  if (json['stats'] != null) {
    stats = CivitaStats.fromJson(json['stats']);
  }

  modelVersions = json['modelVersions']
      .map<CivitaModelVersion>((e) => CivitaModelVersion.fromJson(e))
      .toList();
}