Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
mobile_scanner
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Navaron Bracke
2024-09-18 12:07:12 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1ab7f5a753f9e27c021e780bfa3ac76b8d3cc7b0
1ab7f5a7
1 parent
93e38b4b
add hasCameraPermission getter
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
4 deletions
example/lib/barcode_scanner_controller.dart
lib/src/mobile_scanner.dart
lib/src/objects/mobile_scanner_state.dart
example/lib/barcode_scanner_controller.dart
View file @
1ab7f5a
...
...
@@ -60,7 +60,7 @@ class _BarcodeScannerWithControllerState
@override
void
didChangeAppLifecycleState
(
AppLifecycleState
state
)
{
if
(!
controller
.
value
.
isInitialized
)
{
if
(!
controller
.
value
.
hasCameraPermission
)
{
return
;
}
...
...
lib/src/mobile_scanner.dart
View file @
1ab7f5a
...
...
@@ -281,8 +281,7 @@ class _MobileScannerState extends State<MobileScanner>
@override
void
didChangeAppLifecycleState
(
AppLifecycleState
state
)
{
if
(
widget
.
controller
!=
null
)
return
;
if
(!
controller
.
value
.
isInitialized
)
{
if
(
widget
.
controller
!=
null
||
!
controller
.
value
.
hasCameraPermission
)
{
return
;
}
...
...
lib/src/objects/mobile_scanner_state.dart
View file @
1ab7f5a
import
'dart:ui'
;
import
'package:mobile_scanner/src/enums/camera_facing.dart'
;
import
'package:mobile_scanner/src/enums/mobile_scanner_error_code.dart'
;
import
'package:mobile_scanner/src/enums/torch_state.dart'
;
import
'package:mobile_scanner/src/mobile_scanner_exception.dart'
;
...
...
@@ -43,7 +44,8 @@ class MobileScannerState {
/// Whether the mobile scanner has initialized successfully.
///
/// This is `true` if the camera is ready to be used.
/// This does not indicate that the camera permission was granted.
/// To check if the camera permission was granted, use [hasCameraPermission].
final
bool
isInitialized
;
/// Whether the mobile scanner is currently running.
...
...
@@ -60,6 +62,12 @@ class MobileScannerState {
/// The current zoom scale of the camera.
final
double
zoomScale
;
/// Whether permission to access the camera was granted.
bool
get
hasCameraPermission
{
return
isInitialized
&&
error
?.
errorCode
!=
MobileScannerErrorCode
.
permissionDenied
;
}
/// Create a copy of this state with the given parameters.
MobileScannerState
copyWith
({
int
?
availableCameras
,
...
...
Please
register
or
login
to post a comment