Navaron Bracke

add fromRawValue constructors to camera_facing, detection_speed and torch_state enums

... ... @@ -8,6 +8,17 @@ enum CameraFacing {
const CameraFacing(this.rawValue);
factory CameraFacing.fromRawValue(int value) {
switch (value) {
case 0:
return CameraFacing.front;
case 1:
return CameraFacing.back;
default:
throw ArgumentError.value(value, 'value', 'Invalid raw value.');
}
}
/// The raw value for the camera facing direction.
final int rawValue;
}
... ...
... ... @@ -18,6 +18,19 @@ enum DetectionSpeed {
const DetectionSpeed(this.rawValue);
factory DetectionSpeed.fromRawValue(int value) {
switch (value) {
case 0:
return DetectionSpeed.noDuplicates;
case 1:
return DetectionSpeed.normal;
case 2:
return DetectionSpeed.unrestricted;
default:
return DetectionSpeed.normal;
}
}
/// The raw value for the detection speed.
final int rawValue;
}
... ...
... ... @@ -8,6 +8,17 @@ enum TorchState {
const TorchState(this.rawValue);
factory TorchState.fromRawValue(int value) {
switch (value) {
case 0:
return TorchState.off;
case 1:
return TorchState.on;
default:
throw ArgumentError.value(value, 'value', 'Invalid raw value.');
}
}
/// The raw value for the torch state.
final int rawValue;
}
... ...