setTorchState method

Future<void> setTorchState(
  1. TorchState state
)

Switches flashlight torch operation state (mobile_scanner API compatibility).

Implementation

Future<void> setTorchState(TorchState state) async {
  switch (state) {
    case TorchState.on:
      await setFlashMode(cam.FlashMode.torch);
      break;
    case TorchState.off:
      await setFlashMode(cam.FlashMode.off);
      break;
    case TorchState.auto:
      await setFlashMode(cam.FlashMode.auto);
      break;
    case TorchState.unavailable:
      await setFlashMode(cam.FlashMode.off);
      break;
  }
}