setTorchMode method

  1. @override
Future<void> setTorchMode(
  1. TorchMode mode
)
override

Set the torch mode for a device.

supportedTorchModes should be called before this.

For some platforms, this can override a flash mode.

Implementation

@override
Future<void> setTorchMode(TorchMode mode) {
  verifyInitialized();
  verifyNotDisposed();
  device.device.lockForConfiguration();
  switch (mode) {
    case TorchMode.on:
      device.device.setTorchMode(CaptureTorchMode.on);
      break;
    case TorchMode.off:
      device.device.setTorchMode(CaptureTorchMode.off);
      break;
  }
  return device.device.unlockForConfiguration();
}