Skip to content

Commit c5e0289

Browse files
Merge pull request #1036 from EArminjon/bug/widget-disposed-during-start
fix: widget-disposed-during-start
2 parents c113dff + 2548f3b commit c5e0289

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
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+
16
## 5.0.1
27

38
Improvements:

lib/src/mobile_scanner_controller.dart

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,18 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
274274
options,
275275
);
276276

277-
value = value.copyWith(
278-
availableCameras: viewAttributes.numberOfCameras,
279-
cameraDirection: effectiveDirection,
280-
isInitialized: true,
281-
isRunning: true,
282-
size: viewAttributes.size,
283-
// If the device has a flashlight, let the platform update the torch state.
284-
// If it does not have one, provide the unavailable state directly.
285-
torchState: viewAttributes.hasTorch ? null : TorchState.unavailable,
286-
);
277+
if (!_isDisposed) {
278+
value = value.copyWith(
279+
availableCameras: viewAttributes.numberOfCameras,
280+
cameraDirection: effectiveDirection,
281+
isInitialized: true,
282+
isRunning: true,
283+
size: viewAttributes.size,
284+
// If the device has a flashlight, let the platform update the torch state.
285+
// If it does not have one, provide the unavailable state directly.
286+
torchState: viewAttributes.hasTorch ? null : TorchState.unavailable,
287+
);
288+
}
287289
} on MobileScannerException catch (error) {
288290
// The initialization finished with an error.
289291
// To avoid stale values, reset the output size,

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: mobile_scanner
22
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
44
repository: https://github.com/juliansteenbakker/mobile_scanner
55

66
screenshots:
@@ -24,7 +24,7 @@ dependencies:
2424
sdk: flutter
2525
flutter_web_plugins:
2626
sdk: flutter
27-
plugin_platform_interface: ^2.0.2
27+
plugin_platform_interface: ^2.0.2
2828
web: ^0.5.1
2929

3030
dev_dependencies:

0 commit comments

Comments
 (0)