fromJson static method
Returns a new MmMarketplacePlugin instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static MmMarketplacePlugin? 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(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key), 'Required key "MmMarketplacePlugin[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "MmMarketplacePlugin[$key]" has a null value in JSON.');
});
return true;
}());
return MmMarketplacePlugin(
homepageUrl: mapValueOfType<String>(json, r'homepage_url'),
iconData: mapValueOfType<String>(json, r'icon_data'),
downloadUrl: mapValueOfType<String>(json, r'download_url'),
releaseNotesUrl: mapValueOfType<String>(json, r'release_notes_url'),
labels: json[r'labels'] is List ? (json[r'labels'] as List).cast<String>() : const [],
signature: mapValueOfType<String>(json, r'signature'),
manifest: MmPluginManifest.fromJson(json[r'manifest']),
installedVersion: mapValueOfType<String>(json, r'installed_version'),
);
}
return null;
}