diff --git a/example/pubspec.lock b/example/pubspec.lock index 19f2603..6a34d75 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -28,7 +28,7 @@ packages: name: camera url: "https://pub.dartlang.org" source: hosted - version: "0.9.4+24" + version: "0.9.5+1" camera_platform_interface: dependency: transitive description: @@ -197,7 +197,7 @@ packages: name: image_picker_ios url: "https://pub.dartlang.org" source: hosted - version: "0.8.5+2" + version: "0.8.5+4" image_picker_platform_interface: dependency: transitive description: diff --git a/lib/reader_widget.dart b/lib/reader_widget.dart index b31b6e4..4291c4f 100644 --- a/lib/reader_widget.dart +++ b/lib/reader_widget.dart @@ -41,6 +41,7 @@ class _ReaderWidgetState extends State with TickerProviderStateMixin { List? cameras; CameraController? controller; + var _cameraOn = false; bool isAndroid() => Theme.of(context).platform == TargetPlatform.android; @@ -79,9 +80,11 @@ class _ReaderWidgetState extends State } if (mounted) { if (message == AppLifecycleState.paused.toString()) { - cameraController.dispose(); + _cameraOn = false; + setState(() {}); } if (message == AppLifecycleState.resumed.toString()) { + _cameraOn = true; onNewCameraSelected(cameraController.description); } } @@ -121,6 +124,7 @@ class _ReaderWidgetState extends State }); if (mounted) { + _cameraOn = true; setState(() {}); } @@ -198,7 +202,8 @@ class _ReaderWidgetState extends State if (cameras != null && cameras?.isEmpty == true) { return const Text('No cameras found'); } else if (cameraController == null || - !cameraController.value.isInitialized) { + !cameraController.value.isInitialized || + !_cameraOn) { return const CircularProgressIndicator(); } else { final size = MediaQuery.of(context).size; diff --git a/lib/writer_widget.dart b/lib/writer_widget.dart index 522e22f..dc6fd24 100644 --- a/lib/writer_widget.dart +++ b/lib/writer_widget.dart @@ -12,7 +12,7 @@ class WriterWidget extends StatefulWidget { this.onError, }) : super(key: key); - final Function(EncodeResult, Uint8List)? onSuccess; + final Function(EncodeResult, Uint8List?)? onSuccess; final Function(String)? onError; @override diff --git a/pubspec.yaml b/pubspec.yaml index 077f9e5..162cc98 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,7 +8,7 @@ environment: flutter: ">=2.5.0" dependencies: - camera: ^0.9.4 + camera: ^0.9.5 ffi: ^1.2.1 flutter: sdk: flutter diff --git a/zxscanner/lib/pages/creator_page.dart b/zxscanner/lib/pages/creator_page.dart index ee0a2c5..1d90a04 100644 --- a/zxscanner/lib/pages/creator_page.dart +++ b/zxscanner/lib/pages/creator_page.dart @@ -77,7 +77,7 @@ class _CreatorPageState extends State { return Column( children: [ // Barcode image - Image.memory(encode?.data ?? Uint8List(0)), + if (encode?.data != null) Image.memory(encode?.data ?? Uint8List(0)), const SizedBox(height: spaceLarge), // Share button Row( diff --git a/zxscanner/pubspec.lock b/zxscanner/pubspec.lock index a201c9c..bfb4911 100644 --- a/zxscanner/pubspec.lock +++ b/zxscanner/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "38.0.0" + version: "40.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "3.4.1" + version: "4.1.0" archive: dependency: transitive description: @@ -77,7 +77,7 @@ packages: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "2.1.10" + version: "2.1.11" build_runner_core: dependency: transitive description: @@ -105,7 +105,7 @@ packages: name: camera url: "https://pub.dartlang.org" source: hosted - version: "0.9.4+24" + version: "0.9.5+1" camera_platform_interface: dependency: transitive description: @@ -325,7 +325,7 @@ packages: name: flutter_mobx url: "https://pub.dartlang.org" source: hosted - version: "2.0.5+1" + version: "2.0.6+1" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -370,7 +370,7 @@ packages: name: frontend_server_client url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.3" glob: dependency: transitive description: @@ -391,7 +391,7 @@ packages: name: hive url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.2.1" hive_flutter: dependency: "direct main" description: @@ -405,7 +405,7 @@ packages: name: hive_generator url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.1.3" http: dependency: transitive description: @@ -461,7 +461,7 @@ packages: name: image_picker_ios url: "https://pub.dartlang.org" source: hosted - version: "0.8.5+2" + version: "0.8.5+4" image_picker_platform_interface: dependency: transitive description: @@ -552,21 +552,21 @@ packages: name: mobx url: "https://pub.dartlang.org" source: hosted - version: "2.0.7" + version: "2.0.7+2" mobx_codegen: dependency: "direct dev" description: name: mobx_codegen url: "https://pub.dartlang.org" source: hosted - version: "2.0.6+1" + version: "2.0.7" nb_utils: dependency: "direct main" description: name: nb_utils url: "https://pub.dartlang.org" source: hosted - version: "4.5.1" + version: "4.5.2" nm: dependency: transitive description: @@ -970,7 +970,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.5.2" + version: "2.6.1" xdg_directories: dependency: transitive description: diff --git a/zxscanner/pubspec.yaml b/zxscanner/pubspec.yaml index d49f793..19a7dcf 100644 --- a/zxscanner/pubspec.yaml +++ b/zxscanner/pubspec.yaml @@ -20,13 +20,13 @@ dependencies: flutter_zxing: path: ../ font_awesome_flutter: ^10.1.0 - hive: ^2.1.0 + hive: ^2.2.1 hive_flutter: ^1.1.0 image: ^3.1.3 image_picker: ^0.8.5 intl: ^0.17.0 mobx: ^2.0.7 - nb_utils: ^4.5.1 + nb_utils: ^4.5.2 path_provider: ^2.0.10 share_plus: ^4.0.4 @@ -35,7 +35,7 @@ flutter_intl: enabled: true dev_dependencies: - build_runner: ^2.1.10 + build_runner: ^2.1.11 flutter_lints: ^2.0.1 flutter_test: sdk: flutter