juliansteenbakker / mobile_scanner

A universal scanner for Flutter based on MLKit. Uses CameraX on Android and AVFoundation on iOS.
BSD 3-Clause "New" or "Revised" License
745 stars 444 forks source link

fix: widget-disposed-during-start #1036

Closed EArminjon closed 2 weeks ago

EArminjon commented 3 weeks ago

If mobile_scanner widget is disposed while start the following exception appear :

flutter: Once you have called dispose() on a MobileScannerController, it can no longer be used.
flutter: #0      ChangeNotifier.debugAssertNotDisposed.<anonymous closure> (package:flutter/src/foundation/change_notifier.dart:179:9)
flutter: #1      ChangeNotifier.debugAssertNotDisposed (package:flutter/src/foundation/change_notifier.dart:186:6)
flutter: #2      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:412:27)
flutter: #3      ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:555:5)
flutter: #4      MobileScannerController.start (package:mobile_scanner/src/mobile_scanner_controller.dart:277:7)
EArminjon commented 3 weeks ago

(added exception example)

nishalsehan commented 2 weeks ago

Can you please fix this issue asap.

navaronbracke commented 2 weeks ago

Good catch, we only had a check in the catch block it seems. Can you increment to patch version and update the changelog?

EArminjon commented 2 weeks ago

@navaronbracke done :)

navaronbracke commented 2 weeks ago

I will look into publishing this fix later today.