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
2022-02-28 10:17:04 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1f12854b54e604f071683073f128e74591742177
1f12854b
1 parent
82a16e73
bug: add check to resume start call
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
lib/src/mobile_scanner.dart
lib/src/mobile_scanner_controller.dart
lib/src/mobile_scanner.dart
View file @
1f12854
...
...
@@ -50,7 +50,7 @@ class _MobileScannerState extends State<MobileScanner>
void
didChangeAppLifecycleState
(
AppLifecycleState
state
)
{
switch
(
state
)
{
case
AppLifecycleState
.
resumed
:
controller
.
start
();
if
(!
controller
.
isStarting
)
controller
.
start
();
break
;
case
AppLifecycleState
.
inactive
:
case
AppLifecycleState
.
paused
:
...
...
lib/src/mobile_scanner_controller.dart
View file @
1f12854
...
...
@@ -102,12 +102,18 @@ class MobileScannerController {
// }
// List<BarcodeFormats>? formats = _defaultBarcodeFormats,
bool
isStarting
=
false
;
/// Start barcode scanning. This will first check if the required permissions
/// are set.
Future
<
void
>
start
()
async
{
ensure
(
'startAsync'
);
if
(
isStarting
)
{
throw
Exception
(
'mobile_scanner: Called start() while already starting.'
);
}
isStarting
=
true
;
// setAnalyzeMode(AnalyzeMode.barcode.index);
// Check authorization status
MobileScannerState
state
=
MobileScannerState
.
values
[
await
methodChannel
.
invokeMethod
(
'state'
)];
...
...
@@ -118,6 +124,7 @@ class MobileScannerController {
result
?
MobileScannerState
.
authorized
:
MobileScannerState
.
denied
;
break
;
case
MobileScannerState
.
denied
:
isStarting
=
false
;
throw
PlatformException
(
code:
'NO ACCESS'
);
case
MobileScannerState
.
authorized
:
break
;
...
...
@@ -138,11 +145,13 @@ class MobileScannerController {
'start'
,
arguments
);
}
on
PlatformException
catch
(
error
)
{
debugPrint
(
'
${error.code}
:
${error.message}
'
);
isStarting
=
false
;
// setAnalyzeMode(AnalyzeMode.none.index);
return
;
}
if
(
startResult
==
null
)
{
isStarting
=
false
;
throw
PlatformException
(
code:
'INITIALIZATION ERROR'
);
}
...
...
@@ -151,6 +160,7 @@ class MobileScannerController {
textureId:
startResult
[
'textureId'
],
size:
toSize
(
startResult
[
'size'
]),
hasTorch:
hasTorch
);
isStarting
=
false
;
}
Future
<
void
>
stop
()
async
{
...
...
Please
register
or
login
to post a comment