when<T> method

T when<T>({
  1. T single(
    1. SingleCaptureRequest
    )?,
  2. T multiple(
    1. MultipleCaptureRequest
    )?,
})

Implementation

T when<T>({
  T Function(SingleCaptureRequest)? single,
  T Function(MultipleCaptureRequest)? multiple,
}) {
  if (this is SingleCaptureRequest) {
    return single!(this as SingleCaptureRequest);
  } else if (this is MultipleCaptureRequest) {
    return multiple!(this as MultipleCaptureRequest);
  } else {
    throw Exception("Unknown CaptureResult type");
  }
}