Navaron Bracke

fix bug in app lifecycle guidance

@@ -7,6 +7,9 @@ Improvements: @@ -7,6 +7,9 @@ Improvements:
7 * [web] Added the size information to barcode results. 7 * [web] Added the size information to barcode results.
8 * Added support for barcode formats to image analysis. 8 * Added support for barcode formats to image analysis.
9 * Updated the scanner to report any scanning errors that were encountered during processing. 9 * Updated the scanner to report any scanning errors that were encountered during processing.
  10 +* Introduced a new getter `hasCameraPermission` for the `MobileScannerState`.
  11 +* Fixed a bug in the lifecycle handling sample. Now instead of checking `isInitialized`,
  12 +the sample recommends using `hasCameraPermission`, which also guards against camera permission errors.
10 13
11 Bugs fixed: 14 Bugs fixed:
12 * Fixed a bug that would cause the scanner to emit an error when it was already started. Now it ignores any calls to start while it is starting. 15 * Fixed a bug that would cause the scanner to emit an error when it was already started. Now it ignores any calls to start while it is starting.
@@ -127,7 +127,7 @@ class MyState extends State<MyStatefulWidget> with WidgetsBindingObserver { @@ -127,7 +127,7 @@ class MyState extends State<MyStatefulWidget> with WidgetsBindingObserver {
127 void didChangeAppLifecycleState(AppLifecycleState state) { 127 void didChangeAppLifecycleState(AppLifecycleState state) {
128 // If the controller is not ready, do not try to start or stop it. 128 // If the controller is not ready, do not try to start or stop it.
129 // Permission dialogs can trigger lifecycle changes before the controller is ready. 129 // Permission dialogs can trigger lifecycle changes before the controller is ready.
130 - if (!controller.value.isInitialized) { 130 + if (!controller.value.hasCameraPermission) {
131 return; 131 return;
132 } 132 }
133 133