setFlash method

Future<void> setFlash(
  1. FlashMode mode
)

Implementation

Future<void> setFlash(FlashMode mode) async {
  if (!value.isInitialized! || _isDisposed) {
    throw CameraException(
      'Uninitialized CameraController',
      'resumeVideoRecording was called on uninitialized CameraController',
    );
  }
  String methodName = "";
  switch (mode) {
    case FlashMode.auto:
      methodName = 'setFlashAuto';
      break;
    case FlashMode.on:
      methodName = 'setFlashOn';
      break;
    case FlashMode.off:
      methodName = 'setFlashOff';
      break;
  }

  try {
    await _channel.invokeMethod<void>(
      methodName,
      null,
    );
  } on PlatformException catch (e) {
    throw CameraException(e.code, e.message);
  }
}