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
Julian Steenbakker
2025-01-15 23:43:49 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5c0d5e0c8aee8e7b4af4f1d35b773b0f2731400e
5c0d5e0c
1 parent
9f602a32
imp: add code check for stop
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
lib/src/mobile_scanner_controller.dart
lib/src/mobile_scanner_controller.dart
View file @
5c0d5e0
...
...
@@ -183,13 +183,14 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
}
}
void
_stop
()
{
/// Returns false if stop is called but not necessary, otherwise true is returned.
bool
_stop
()
{
// Do nothing if not initialized or already stopped.
// On the web, the permission popup triggers a lifecycle change from resumed to inactive,
// due to the permission popup gaining focus.
// This would 'stop' the camera while it is not ready yet.
if
(!
value
.
isInitialized
||
!
value
.
isRunning
||
_isDisposed
)
{
return
;
return
false
;
}
_disposeListeners
();
...
...
@@ -205,6 +206,7 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
?
TorchState
.
unavailable
:
TorchState
.
off
,
);
return
true
;
}
/// Analyze an image file.
...
...
@@ -360,8 +362,9 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
///
/// Does nothing if the camera is already stopped.
Future
<
void
>
stop
()
async
{
_stop
();
await
MobileScannerPlatform
.
instance
.
stop
();
if
(
_stop
())
{
await
MobileScannerPlatform
.
instance
.
stop
();
}
}
/// Pause the camera.
...
...
@@ -371,8 +374,9 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
///
/// Does nothing if the camera is already paused or stopped.
Future
<
void
>
pause
()
async
{
_stop
();
await
MobileScannerPlatform
.
instance
.
pause
();
if
(
_stop
())
{
await
MobileScannerPlatform
.
instance
.
pause
();
}
}
/// Switch between the front and back camera.
...
...
Please
register
or
login
to post a comment