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-01-02 14:18:55 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f2f16e9a8ce32f50aff061ba81105a51e3fc77c9
f2f16e9a
1 parent
169728a0
do nothing in start/stop if already started/stopped
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
lib/src/mobile_scanner_controller.dart
lib/src/mobile_scanner_controller.dart
View file @
f2f16e9
...
...
@@ -205,6 +205,8 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
///
/// The [cameraDirection] can be used to specify the camera direction.
/// If this is null, this defaults to the [facing] value.
///
/// Does nothing if the camera is already running.
Future
<
void
>
start
({
CameraFacing
?
cameraDirection
})
async
{
if
(
_isDisposed
)
{
throw
const
MobileScannerException
(
...
...
@@ -216,6 +218,11 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
);
}
// Do nothing if the camera is already running.
if
(
value
.
isRunning
)
{
return
;
}
final
CameraFacing
effectiveDirection
=
cameraDirection
??
facing
;
final
StartOptions
options
=
StartOptions
(
...
...
@@ -267,11 +274,18 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
/// Stop the camera.
///
/// After calling this method, the camera can be restarted using [start].
///
/// Does nothing if the camera is already stopped.
Future
<
void
>
stop
()
async
{
_disposeListeners
();
_throwIfNotInitialized
();
// Do nothing if already stopped.
if
(!
value
.
isRunning
)
{
return
;
}
_disposeListeners
();
// 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
(
...
...
Please
register
or
login
to post a comment