Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Official document error #1240

Open
jsleemaster opened this issue Nov 13, 2024 · 5 comments
Open

Official document error #1240

jsleemaster opened this issue Nov 13, 2024 · 5 comments

Comments

@jsleemaster
Copy link

Error

The getter 'hasCameraPermission' isn't defined for the type 'MobileScannerState'.
Try importing the library that defines 'hasCameraPermission', correcting the name to the name of an existing getter, or defining a getter or field named 'hasCameraPermission'.

There is an error with the hasCameraPermission option in the idChangeAppLifeState method part in the official document. Which part should it be replaced with? Can you correct it?

Currently, I am checking with isInitialized option.

@navaronbracke
Copy link
Collaborator

This getter is defined here: https://github.com/juliansteenbakker/mobile_scanner/blob/master/lib/src/objects/mobile_scanner_state.dart#L66

What version of mobile_scanner are you using? The getter was introduced in version 6.0.0, as stated in the changelog.

https://github.com/juliansteenbakker/mobile_scanner/blob/master/CHANGELOG.md#600

If you do not want to upgrade to that version, you can just do the check yourself, too.

For that, you'll need to check both isInitialized and error?.errorCode != MobileScannerErrorCode.permissionDenied

@hailuongsl97
Copy link

hailuongsl97 commented Nov 21, 2024

Screenshot 2024-11-21 at 09 38 22
Hello @navaronbracke
I same issue!
I has check code, default isInitialized is false => hasCameraPermission is false
and isInitialized set is true when call start()
please fix this issue

@navaronbracke
Copy link
Collaborator

@hailuongsl97 What version of mobile_scanner are you using? The getter hasCameraPermission is introduced in version 6.0.0, with a workaround for version 5.0.0, as stated above.

@hailuongsl97
Copy link

@hailuongsl97 What version of mobile_scanner are you using? The getter hasCameraPermission is introduced in version 6.0.0, with a workaround for version 5.0.0, as stated above.

I use mobile_scanner v 6.0.2

@navaronbracke
Copy link
Collaborator

@hailuongsl97 I do not understand what problem your are encountering? You can use hasCameraPermission in didChangeAppLifecycleState, to determine if the controller should be started when the application is resumed.
See the example at https://github.com/juliansteenbakker/mobile_scanner/blob/master/example/lib/barcode_scanner_controller.dart#L62-L81

Or are you referring to a different issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants