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
2023-11-09 09:05:28 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ee05a6eefaa20162de6d374dee35107a3f57f39b
ee05a6ee
1 parent
bb808d07
add an isRunning flag to the scanner state
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletions
lib/src/mobile_scanner_controller.dart
lib/src/objects/mobile_scanner_state.dart
lib/src/mobile_scanner_controller.dart
View file @
ee05a6e
...
...
@@ -230,12 +230,14 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
value
=
value
.
copyWith
(
cameraDirection:
effectiveDirection
,
isInitialized:
true
,
isRunning:
true
,
size:
viewAttributes
.
size
,
// If the device has a flashlight, let the platform update the torch state.
// If it does not have one, provide the unavailable state directly.
torchState:
viewAttributes
.
hasTorch
?
null
:
TorchState
.
unavailable
,
);
}
on
MobileScannerException
catch
(
error
)
{
// The initialization finished with an error.
if
(!
_isDisposed
)
{
value
=
value
.
copyWith
(
cameraDirection:
facing
,
...
...
@@ -258,7 +260,10 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
// After the camera stopped, set the torch state to off,
// as the torch state callback is never called when the camera is stopped.
value
=
value
.
copyWith
(
torchState:
TorchState
.
off
);
value
=
value
.
copyWith
(
isRunning:
false
,
torchState:
TorchState
.
off
,
);
}
/// Switch between the front and back camera.
...
...
lib/src/objects/mobile_scanner_state.dart
View file @
ee05a6e
...
...
@@ -10,6 +10,7 @@ class MobileScannerState {
const
MobileScannerState
({
required
this
.
cameraDirection
,
required
this
.
isInitialized
,
required
this
.
isRunning
,
required
this
.
size
,
required
this
.
torchState
,
required
this
.
zoomScale
,
...
...
@@ -21,6 +22,7 @@ class MobileScannerState {
:
this
(
cameraDirection:
facing
,
isInitialized:
false
,
isRunning:
false
,
size:
Size
.
zero
,
torchState:
TorchState
.
unavailable
,
zoomScale:
1.0
,
...
...
@@ -33,8 +35,15 @@ class MobileScannerState {
final
MobileScannerException
?
error
;
/// Whether the mobile scanner has initialized successfully.
///
/// This is `true` if the camera is ready to be used.
final
bool
isInitialized
;
/// Whether the mobile scanner is currently running.
///
/// This is `true` if the camera is active.
final
bool
isRunning
;
/// The size of the camera output.
final
Size
size
;
...
...
@@ -49,6 +58,7 @@ class MobileScannerState {
CameraFacing
?
cameraDirection
,
MobileScannerException
?
error
,
bool
?
isInitialized
,
bool
?
isRunning
,
Size
?
size
,
TorchState
?
torchState
,
double
?
zoomScale
,
...
...
@@ -57,6 +67,7 @@ class MobileScannerState {
cameraDirection:
cameraDirection
??
this
.
cameraDirection
,
error:
error
,
isInitialized:
isInitialized
??
this
.
isInitialized
,
isRunning:
isRunning
??
this
.
isRunning
,
size:
size
??
this
.
size
,
torchState:
torchState
??
this
.
torchState
,
zoomScale:
zoomScale
??
this
.
zoomScale
,
...
...
Please
register
or
login
to post a comment