capturePropertyFromProperty function
Helper for determining which property should be assigned to the value (used in response) property.
Implementation
CaptureProperty capturePropertyFromProperty(Property prop) {
final int id = prop.id ?? (throw StateError('Property ID cannot be null'));
final int type =
prop.type ?? (throw StateError('Property type cannot be null'));
dynamic value = <dynamic, dynamic>{};
switch (type) {
case CapturePropertyTypes.dataSource:
value = prop.dataSourceValue;
break;
case CapturePropertyTypes.array:
value = prop.arrayValue;
break;
case CapturePropertyTypes.string:
value = prop.stringValue;
break;
case CapturePropertyTypes.byte:
value = prop.byteValue;
break;
case CapturePropertyTypes.ulong:
value = prop.longValue;
break;
case CapturePropertyTypes.object:
value = prop.objectValue;
break;
case CapturePropertyTypes.version:
value = prop.versionValue;
break;
// case CapturePropertyTypes.Enum:
// value = prop.enumValue;
// break;
}
return CaptureProperty(id: id, type: type, value: value);
}