fromJson static method
Returns a new SlotView instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static SlotView? 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 "SlotView[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "SlotView[$key]" has a null value in JSON.');
});
return true;
}());
return SlotView(
blsPubkey: mapValueOfType<String>(json, r'blsPubkey'),
crName: mapValueOfType<String>(json, r'crName'),
createdAt: mapValueOfType<int>(json, r'createdAt'),
namespace: mapValueOfType<String>(json, r'namespace'),
network: mapValueOfType<String>(json, r'network'),
nodeID: mapValueOfType<String>(json, r'nodeID'),
nodeStatus: mapValueOfType<String>(json, r'nodeStatus'),
registration: RegistrationView.fromJson(json[r'registration']),
slot: mapValueOfType<int>(json, r'slot'),
tokenId: mapValueOfType<int>(json, r'tokenId'),
updatedAt: mapValueOfType<int>(json, r'updatedAt'),
wallet: mapValueOfType<String>(json, r'wallet'),
);
}
return null;
}