Skip to content

Commit

Permalink
Merge pull request #1036 from EArminjon/bug/widget-disposed-during-start
Browse files Browse the repository at this point in the history
fix: widget-disposed-during-start
  • Loading branch information
navaronbracke authored Apr 30, 2024
2 parents c113dff + 2548f3b commit c5e0289
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 5.0.2

Bugs fixed:
* 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.0.1

Improvements:
Expand Down
22 changes: 12 additions & 10 deletions lib/src/mobile_scanner_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,18 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
options,
);

value = value.copyWith(
availableCameras: viewAttributes.numberOfCameras,
cameraDirection: effectiveDirection,
isInitialized: true,
isRunning: true,
size: viewAttributes.size,
// If the device has a flashlight, let the platform update the torch state.
// If it does not have one, provide the unavailable state directly.
torchState: viewAttributes.hasTorch ? null : TorchState.unavailable,
);
if (!_isDisposed) {
value = value.copyWith(
availableCameras: viewAttributes.numberOfCameras,
cameraDirection: effectiveDirection,
isInitialized: true,
isRunning: true,
size: viewAttributes.size,
// If the device has a flashlight, let the platform update the torch state.
// If it does not have one, provide the unavailable state directly.
torchState: viewAttributes.hasTorch ? null : TorchState.unavailable,
);
}
} on MobileScannerException catch (error) {
// The initialization finished with an error.
// To avoid stale values, reset the output size,
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mobile_scanner
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.
version: 5.0.1
version: 5.0.2
repository: https://github.com/juliansteenbakker/mobile_scanner

screenshots:
Expand All @@ -24,7 +24,7 @@ dependencies:
sdk: flutter
flutter_web_plugins:
sdk: flutter
plugin_platform_interface: ^2.0.2
plugin_platform_interface: ^2.0.2
web: ^0.5.1

dev_dependencies:
Expand Down

0 comments on commit c5e0289

Please sign in to comment.