fromJson static method
Returns a new SpatioFile instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static SpatioFile? 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(() {
assert(json.containsKey(r'id'), 'Required key "SpatioFile[id]" is missing from JSON.');
assert(json[r'id'] != null, 'Required key "SpatioFile[id]" has a null value in JSON.');
assert(json.containsKey(r'name'), 'Required key "SpatioFile[name]" is missing from JSON.');
assert(json[r'name'] != null, 'Required key "SpatioFile[name]" has a null value in JSON.');
assert(json.containsKey(r'size'), 'Required key "SpatioFile[size]" is missing from JSON.');
assert(json[r'size'] != null, 'Required key "SpatioFile[size]" has a null value in JSON.');
assert(json.containsKey(r'mimeType'), 'Required key "SpatioFile[mimeType]" is missing from JSON.');
assert(json[r'mimeType'] != null, 'Required key "SpatioFile[mimeType]" has a null value in JSON.');
assert(json.containsKey(r'storageType'), 'Required key "SpatioFile[storageType]" is missing from JSON.');
assert(json[r'storageType'] != null, 'Required key "SpatioFile[storageType]" has a null value in JSON.');
assert(json.containsKey(r'createdAt'), 'Required key "SpatioFile[createdAt]" is missing from JSON.');
assert(json[r'createdAt'] != null, 'Required key "SpatioFile[createdAt]" has a null value in JSON.');
assert(json.containsKey(r'updatedAt'), 'Required key "SpatioFile[updatedAt]" is missing from JSON.');
assert(json[r'updatedAt'] != null, 'Required key "SpatioFile[updatedAt]" has a null value in JSON.');
return true;
}());
return SpatioFile(
id: mapValueOfType<String>(json, r'id')!,
provider: mapValueOfType<String>(json, r'provider'),
accountId: mapValueOfType<String>(json, r'accountId'),
name: mapValueOfType<String>(json, r'name')!,
size: mapValueOfType<int>(json, r'size')!,
mimeType: mapValueOfType<String>(json, r'mimeType')!,
folderId: mapValueOfType<String>(json, r'folderId'),
storageType: mapValueOfType<String>(json, r'storageType')!,
downloadUrl: mapValueOfType<String>(json, r'downloadUrl'),
metadata: mapCastOfType<String, Object>(json, r'metadata') ?? const {},
createdAt: mapDateTime(json, r'createdAt', r'')!,
updatedAt: mapDateTime(json, r'updatedAt', r'')!,
);
}
return null;
}