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-04-18 13:59:06 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
594b58379feaedde96bc845139427a3b7969581c
594b5837
1 parent
7861d906
fix: remove unnecessary stream pause on inactive, only use observer when no controller is passed
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
10 deletions
lib/src/mobile_scanner.dart
lib/src/mobile_scanner.dart
View file @
594b583
...
...
@@ -271,7 +271,7 @@ class _MobileScannerState extends State<MobileScanner>
// }
// }
if
(
widget
.
onDetect
!
=
null
)
{
if
(
widget
.
controller
=
=
null
)
{
WidgetsBinding
.
instance
.
addObserver
(
this
);
_subscription
=
controller
.
barcodes
.
listen
(
widget
.
onDetect
,
...
...
@@ -285,7 +285,7 @@ class _MobileScannerState extends State<MobileScanner>
}
Future
<
void
>
disposeMobileScanner
()
async
{
if
(
widget
.
onDetect
!
=
null
)
{
if
(
widget
.
controller
=
=
null
)
{
WidgetsBinding
.
instance
.
removeObserver
(
this
);
}
...
...
@@ -317,7 +317,7 @@ class _MobileScannerState extends State<MobileScanner>
@override
void
didChangeAppLifecycleState
(
AppLifecycleState
state
)
{
if
(
widget
.
controller
!=
null
||
!
controller
.
value
.
hasCameraPermission
)
{
if
(!
controller
.
value
.
hasCameraPermission
)
{
return
;
}
...
...
@@ -327,15 +327,8 @@ class _MobileScannerState extends State<MobileScanner>
case
AppLifecycleState
.
paused
:
return
;
case
AppLifecycleState
.
resumed
:
_subscription
=
controller
.
barcodes
.
listen
(
widget
.
onDetect
,
onError:
widget
.
onDetectError
,
cancelOnError:
false
,
);
unawaited
(
controller
.
start
());
case
AppLifecycleState
.
inactive
:
unawaited
(
_subscription
?.
cancel
());
unawaited
(
controller
.
stop
());
}
}
...
...
Please
register
or
login
to post a comment