fromJson static method
Sheet?
fromJson(
- dynamic value
)
Returns a new Sheet instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static Sheet? 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 "Sheet[id]" is missing from JSON.');
assert(json[r'id'] != null, 'Required key "Sheet[id]" has a null value in JSON.');
assert(json.containsKey(r'name'), 'Required key "Sheet[name]" is missing from JSON.');
assert(json[r'name'] != null, 'Required key "Sheet[name]" has a null value in JSON.');
assert(json.containsKey(r'rowCount'), 'Required key "Sheet[rowCount]" is missing from JSON.');
assert(json[r'rowCount'] != null, 'Required key "Sheet[rowCount]" has a null value in JSON.');
assert(json.containsKey(r'columnCount'), 'Required key "Sheet[columnCount]" is missing from JSON.');
assert(json[r'columnCount'] != null, 'Required key "Sheet[columnCount]" has a null value in JSON.');
assert(json.containsKey(r'sheetCount'), 'Required key "Sheet[sheetCount]" is missing from JSON.');
assert(json[r'sheetCount'] != null, 'Required key "Sheet[sheetCount]" has a null value in JSON.');
assert(json.containsKey(r'isPublic'), 'Required key "Sheet[isPublic]" is missing from JSON.');
assert(json[r'isPublic'] != null, 'Required key "Sheet[isPublic]" has a null value in JSON.');
assert(json.containsKey(r'isReadOnly'), 'Required key "Sheet[isReadOnly]" is missing from JSON.');
assert(json[r'isReadOnly'] != null, 'Required key "Sheet[isReadOnly]" has a null value in JSON.');
assert(json.containsKey(r'createdAt'), 'Required key "Sheet[createdAt]" is missing from JSON.');
assert(json[r'createdAt'] != null, 'Required key "Sheet[createdAt]" has a null value in JSON.');
assert(json.containsKey(r'updatedAt'), 'Required key "Sheet[updatedAt]" is missing from JSON.');
assert(json[r'updatedAt'] != null, 'Required key "Sheet[updatedAt]" has a null value in JSON.');
return true;
}());
return Sheet(
id: mapValueOfType<String>(json, r'id')!,
provider: mapValueOfType<String>(json, r'provider'),
accountId: mapValueOfType<String>(json, r'accountId'),
ownerUserId: mapValueOfType<String>(json, r'ownerUserId'),
name: mapValueOfType<String>(json, r'name')!,
description: mapValueOfType<String>(json, r'description'),
data: mapCastOfType<String, Object>(json, r'data') ?? const {},
rowCount: mapValueOfType<int>(json, r'rowCount')!,
columnCount: mapValueOfType<int>(json, r'columnCount')!,
sheetCount: mapValueOfType<int>(json, r'sheetCount')!,
isPublic: mapValueOfType<bool>(json, r'isPublic')!,
isReadOnly: mapValueOfType<bool>(json, r'isReadOnly')!,
fileSize: mapValueOfType<int>(json, r'fileSize'),
lastAccessedAt: mapDateTime(json, r'lastAccessedAt', r''),
createdAt: mapDateTime(json, r'createdAt', r'')!,
updatedAt: mapDateTime(json, r'updatedAt', r'')!,
);
}
return null;
}