Skip to content

Commit

Permalink
reset the scanner error when stop finished
Browse files Browse the repository at this point in the history
  • Loading branch information
navaronbracke committed Nov 26, 2024
1 parent 4cc4287 commit d78cc28
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/src/mobile_scanner_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,27 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
torchState: oldTorchState == TorchState.unavailable
? TorchState.unavailable
: TorchState.off,
resetError: true,
);

await MobileScannerPlatform.instance.stop();
try {
await MobileScannerPlatform.instance.stop();
} catch (error, stackTrace) {
if (_isDisposed) {
return;
}

// If the camera failed to stop, report the error.
value = value.copyWith(
error: MobileScannerException(
errorCode: MobileScannerErrorCode.genericError,
errorDetails: MobileScannerErrorDetails(
details: stackTrace.toString(),
message: error.toString(),
),
),
);
}
}

/// Switch between the front and back camera.
Expand Down

0 comments on commit d78cc28

Please sign in to comment.