khoren93 / flutter_zxing

Flutter plugin for scanning and generating QR codes using the ZXing library, supporting Android, iOS, and desktop platforms
https://pub.dev/packages/flutter_zxing
MIT License
92 stars 52 forks source link

A CameraController was used after being disposed #23

Closed LinHaoLove closed 1 year ago

LinHaoLove commented 2 years ago

hi,sir, On iOS, Only after the first installation and permission, the following error will appear. When I try to use the cameracontroller to avoid this problem, I cannot refer to it. However, this error did not affect the normal operation of the program , But the picture in the camera is shaking badly. It didn't happen yesterday, it often happens today

flutter: AppLifecycleState.resumed [VERBOSE-2:ui_dart_state.cc(198)] Unhandled Exception: A CameraController was used after being disposed. Once you have called dispose() on a CameraController, it can no longer be used.

0 ChangeNotifier._debugAssertNotDisposed. (package:flutter/src/foundation/change_notifier.dart:125:9)

1 ChangeNotifier._debugAssertNotDisposed (package:flutter/src/foundation/change_notifier.dart:131:6)

2 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:304:12)

3 ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:428:5)

4 CameraController.setFlashMode (package:camera/src/camera_controller.dart:624:7)

#5 _ReaderWidgetState.onNewCameraSelected (package:flutter_zxing/src/ui/reader_widget.dart:132:7) On Android, I got seven warnings, I'm not sure if it's the reference of this plug-in. But I don't use the camera anywhere else. After sudo rm -rf .pub-cache,it is ok. like this my_flutter_stable_sdk/flutter/.pub-cache/hosted/pub.flutter-io.cn/camera_android-0.10.0+1/android/src/main/java/io/flutter/plugins/camera/features/resolution/ResolutionFeature.java:154: 警告: [deprecation] CamcorderProfile中的get(int,int)已过时 return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_HIGH); CamcorderProfile.QUALITY_2160P, CamcorderProfile.QUALITY_1080P, CamcorderProfile.QUALITY_720P, CamcorderProfile.QUALITY_480P, CamcorderProfile.QUALITY_QVGA CamcorderProfile.QUALITY_LOW
LinHaoLove commented 2 years ago

Thank you for have a look.

PermissionStatus state = await Permission.camera.request(); if (state.isGranted==true){ pushViewController(context: context, child: const GatewayQrCodeScannerWidget()); }else{ //Here's the hint }