fromJson static method
Returns a new ModelDetail instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static ModelDetail? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
return true;
}());
return ModelDetail(
id: mapValueOfType<String>(json, r'id'),
author: mapValueOfType<String>(json, r'author'),
name: mapValueOfType<String>(json, r'name'),
primaryMethod: mapValueOfType<String>(json, r'primary_method'),
secondaryMethods: mapValueOfType<String>(json, r'secondary_methods'),
confidence: mapValueOfType<String>(json, r'confidence'),
classificationEvidence: mapValueOfType<String>(json, r'classification_evidence'),
classifierVersion: mapValueOfType<String>(json, r'classifier_version'),
classifiedAt: mapValueOfType<String>(json, r'classified_at'),
family: mapValueOfType<String>(json, r'family'),
paramsB: json[r'params_b'] == null
? null
: num.parse('${json[r'params_b']}'),
isGguf: mapValueOfType<int>(json, r'is_gguf'),
isMoe: mapValueOfType<int>(json, r'is_moe'),
isMultimodal: mapValueOfType<int>(json, r'is_multimodal'),
isImageGen: mapValueOfType<int>(json, r'is_image_gen'),
isSecondOrder: mapValueOfType<int>(json, r'is_second_order'),
downloads: mapValueOfType<int>(json, r'downloads'),
likes: mapValueOfType<int>(json, r'likes'),
createdAt: mapValueOfType<String>(json, r'created_at'),
lastModified: mapValueOfType<String>(json, r'last_modified'),
firstSeenAt: mapValueOfType<String>(json, r'first_seen_at'),
lastSeenAt: mapValueOfType<String>(json, r'last_seen_at'),
isDelisted: mapValueOfType<int>(json, r'is_delisted'),
daysSinceGone: mapValueOfType<int>(json, r'days_since_gone'),
readmeText: mapValueOfType<String>(json, r'readme_text'),
readmeStatus: mapValueOfType<String>(json, r'readme_status'),
tags: mapValueOfType<String>(json, r'tags'),
pipelineTag: mapValueOfType<String>(json, r'pipeline_tag'),
libraryName: mapValueOfType<String>(json, r'library_name'),
yamlBaseModel: mapValueOfType<String>(json, r'yaml_base_model'),
yamlLanguage: mapValueOfType<String>(json, r'yaml_language'),
yamlDatasets: mapValueOfType<String>(json, r'yaml_datasets'),
yamlLicense: mapValueOfType<String>(json, r'yaml_license'),
yamlTags: mapValueOfType<String>(json, r'yaml_tags'),
filesCount: mapValueOfType<int>(json, r'files_count'),
totalSizeBytes: mapValueOfType<int>(json, r'total_size_bytes'),
largestFileBytes: mapValueOfType<int>(json, r'largest_file_bytes'),
smallestModelBytes: mapValueOfType<int>(json, r'smallest_model_bytes'),
quantizations: mapValueOfType<String>(json, r'quantizations'),
hasMmproj: mapValueOfType<int>(json, r'has_mmproj'),
hubDownloadsAllTime: mapValueOfType<int>(json, r'hub_downloads_all_time'),
hubTrendingScore: mapValueOfType<int>(json, r'hub_trending_score'),
hubRealParamsM: json[r'hub_real_params_m'] == null
? null
: num.parse('${json[r'hub_real_params_m']}'),
hubContextLength: mapValueOfType<int>(json, r'hub_context_length'),
hubSiblingsCount: mapValueOfType<int>(json, r'hub_siblings_count'),
hubProviderCount: mapValueOfType<int>(json, r'hub_provider_count'),
hubProviderNames: mapValueOfType<String>(json, r'hub_provider_names'),
hubEnrichedAt: mapValueOfType<String>(json, r'hub_enriched_at'),
files: json[r'files'] is Iterable
? (json[r'files'] as Iterable).cast<Object>().toList(growable: false)
: const [],
benchmarks: mapValueOfType<Object>(json, r'benchmarks'),
authorSummary: Author.fromJson(json[r'author_summary']),
);
}
return null;
}