setTorch method

Future<void> setTorch(
  1. TorchMode mode
)

Implementation

Future<void> setTorch(TorchMode mode) async {
  if (!value.isInitialized! || _isDisposed) {
    throw CameraException(
      'Uninitialized CameraController',
      'resumeVideoRecording was called on uninitialized CameraController',
    );
  }
  String methodName = (mode == TorchMode.off) ? 'setTorchOff' : 'setTorchOn';
  try {
    await _channel.invokeMethod<void>(
      methodName,
      null,
    );
  } on PlatformException catch (e) {
    throw CameraException(e.code, e.message);
  }
}