Navaron Bracke
Committed by GitHub

Merge pull request #1036 from EArminjon/bug/widget-disposed-during-start

fix: widget-disposed-during-start
  1 +## 5.0.2
  2 +
  3 +Bugs fixed:
  4 +* Fixed a crash when the controller is disposed while it is still starting. [#1036](https://github.com/juliansteenbakker/mobile_scanner/pull/1036) (thanks @EArminjon !)
  5 +
1 ## 5.0.1 6 ## 5.0.1
2 7
3 Improvements: 8 Improvements:
@@ -274,6 +274,7 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> { @@ -274,6 +274,7 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
274 options, 274 options,
275 ); 275 );
276 276
  277 + if (!_isDisposed) {
277 value = value.copyWith( 278 value = value.copyWith(
278 availableCameras: viewAttributes.numberOfCameras, 279 availableCameras: viewAttributes.numberOfCameras,
279 cameraDirection: effectiveDirection, 280 cameraDirection: effectiveDirection,
@@ -284,6 +285,7 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> { @@ -284,6 +285,7 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
284 // If it does not have one, provide the unavailable state directly. 285 // If it does not have one, provide the unavailable state directly.
285 torchState: viewAttributes.hasTorch ? null : TorchState.unavailable, 286 torchState: viewAttributes.hasTorch ? null : TorchState.unavailable,
286 ); 287 );
  288 + }
287 } on MobileScannerException catch (error) { 289 } on MobileScannerException catch (error) {
288 // The initialization finished with an error. 290 // The initialization finished with an error.
289 // To avoid stale values, reset the output size, 291 // To avoid stale values, reset the output size,
1 name: mobile_scanner 1 name: mobile_scanner
2 description: A universal barcode and QR code scanner for Flutter based on MLKit. Uses CameraX on Android, AVFoundation on iOS and Apple Vision & AVFoundation on macOS. 2 description: A universal barcode and QR code scanner for Flutter based on MLKit. Uses CameraX on Android, AVFoundation on iOS and Apple Vision & AVFoundation on macOS.
3 -version: 5.0.1 3 +version: 5.0.2
4 repository: https://github.com/juliansteenbakker/mobile_scanner 4 repository: https://github.com/juliansteenbakker/mobile_scanner
5 5
6 screenshots: 6 screenshots: