when method

dynamic when({
  1. OnVideoMode? onVideoMode,
  2. OnPhotoMode? onPhotoMode,
  3. OnPreparingCamera? onPreparingCamera,
  4. OnVideoRecordingMode? onVideoRecordingMode,
  5. OnPreviewMode? onPreviewMode,
  6. OnAnalysisOnlyMode? onAnalysisOnlyMode,
})

Implementation

when({
  OnVideoMode? onVideoMode,
  OnPhotoMode? onPhotoMode,
  OnPreparingCamera? onPreparingCamera,
  OnVideoRecordingMode? onVideoRecordingMode,
  OnPreviewMode? onPreviewMode,
  OnAnalysisOnlyMode? onAnalysisOnlyMode,
}) {
  return switch (this) {
    (VideoCameraState state) => onVideoMode?.call(state),
    (PhotoCameraState state) => onPhotoMode?.call(state),
    (PreparingCameraState state) => onPreparingCamera?.call(state),
    (VideoRecordingCameraState state) => onVideoRecordingMode?.call(state),
    (PreviewCameraState state) => onPreviewMode?.call(state),
    (AnalysisCameraState state) => onAnalysisOnlyMode?.call(state),
    CameraState() => null,
  };
}