fromDynamic static method
Deserializes the command from a Map or a map-like object into the the
proper data model. This will throw an exception if map
is null.
Implementation
static DeviceCommand fromDynamic(dynamic map) {
late DeviceCommand result;
if (map == null) {
throw Exception('[DeviceCommand.fromDynamic]: map is null');
} else {
final cmd = DeviceCommand(
id: map['id'],
type: map['type'],
payload: map['payload'],
timestamp: JsonClass.parseUtcMillis(map['timestamp']),
);
result = cmd;
final builder = _builders[cmd.type];
if (builder != null) {
result = builder(cmd.payload, cmd.id, cmd.timestamp);
}
}
return result;
}