changeFlashMode method

void changeFlashMode()

Implementation

void changeFlashMode() async {
  if (!initialized) {
    _uiHandler.showSnackBar('Couldn\'t find the camera!');
    return;
  }

  try {
    final mode = controller.value.flashMode == FlashMode.off
        ? FlashMode.always
        : FlashMode.off;
    value = value.copyWith(flashMode: mode);
    log('FLASH TYPE ${value.cameraType.value}');
    log('FLASH MODE ${value.flashMode.index}');
    await controller.setFlashMode(mode);
  } on CameraException catch (e) {
    _uiHandler.showExceptionSnackbar(e);
    rethrow;
  }
}