takePictureAndDecode method

Future<void> takePictureAndDecode()

Implementation

Future<void> takePictureAndDecode() async {
  if (state.value.processing) return;
  state.value = state.value.copyWith(
    processing: true,
  );
  final xFile = await cameraController?.takePicture();

  if (xFile != null) {
    final decoded = await _codeDartScanDecoder?.decodeFile(
      xFile,
      scanInverted: _scanInvertedQRCode,
    );
    state.value = state.value.copyWith(
      result: decoded,
    );
  }

  state.value = state.value.copyWith(
    processing: false,
  );
}