fromJson static method
Returns a new AttachmentEntity instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static AttachmentEntity? 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 "AttachmentEntity[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "AttachmentEntity[$key]" has a null value in JSON.');
});
return true;
}());
return AttachmentEntity(
id: mapValueOfType<String>(json, r'id'),
attachmentId: mapValueOfType<String>(json, r'attachmentId')!,
bucket: mapValueOfType<String>(json, r'bucket'),
userId: mapValueOfType<String>(json, r'userId')!,
contentType: mapValueOfType<String>(json, r'contentType'),
contentLength: mapValueOfType<int>(json, r'contentLength'),
name: mapValueOfType<String>(json, r'name'),
createdAt: mapDateTime(json, r'createdAt', '')!,
updatedAt: mapDateTime(json, r'updatedAt', '')!,
);
}
return null;
}