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
2023-12-05 10:30:48 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
327a114f85f085217963f85fe7fbf3cd8aea3e4e
327a114f
1 parent
91a0394b
bug: fix stream controller not being closed
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
9 deletions
lib/mobile_scanner_web_plugin.dart
lib/src/web/base.dart
lib/src/web/jsqr.dart
lib/src/web/zxing.dart
lib/mobile_scanner_web_plugin.dart
View file @
327a114
...
...
@@ -186,7 +186,8 @@ class MobileScannerWebPlugin {
/// Stops the video feed and analyzer
Future
<
void
>
cancel
()
async
{
barCodeReader
.
stop
();
await
barCodeReader
.
stop
();
await
barCodeReader
.
stopDetectBarcodeContinuously
();
await
_barCodeStreamSubscription
?.
cancel
();
_barCodeStreamSubscription
=
null
;
}
...
...
lib/src/web/base.dart
View file @
327a114
...
...
@@ -50,6 +50,9 @@ abstract class WebBarcodeReaderBase {
/// Starts scanning QR codes or barcodes
Stream
<
Barcode
?>
detectBarcodeContinuously
();
/// Stops scanning QR codes or barcodes
Future
<
void
>
stopDetectBarcodeContinuously
();
/// Stops streaming video
Future
<
void
>
stop
();
...
...
lib/src/web/jsqr.dart
View file @
327a114
...
...
@@ -83,6 +83,11 @@ class JsQrCodeReader extends WebBarcodeReaderBase
});
}
@override
Future
<
void
>
stopDetectBarcodeContinuously
()
async
{
return
;
}
/// Captures a frame and analyzes it for QR codes
Future
<
Code
?>
_captureFrame
(
VideoElement
video
)
async
{
if
(
localMediaStream
==
null
)
return
null
;
...
...
lib/src/web/zxing.dart
View file @
327a114
...
...
@@ -250,24 +250,30 @@ class ZXingBarcodeReader extends WebBarcodeReaderBase
await
videoSource
.
play
();
}
StreamController
<
Barcode
?>?
controller
;
@override
Future
<
void
>
stopDetectBarcodeContinuously
()
async
{
_reader
?.
stopContinuousDecode
();
controller
?.
close
();
controller
=
null
;
}
@override
Stream
<
Barcode
?>
detectBarcodeContinuously
()
{
final
controller
=
StreamController
<
Barcode
?>();
controller
.
onListen
=
()
async
{
controller
??=
StreamController
<
Barcode
?>();
controller
!.
onListen
=
()
async
{
_reader
?.
decodeContinuously
(
video
,
allowInterop
((
result
,
error
)
{
if
(
result
!=
null
)
{
controller
.
add
(
result
.
toBarcode
());
controller
?
.
add
(
result
.
toBarcode
());
}
}),
);
};
controller
.
onCancel
=
()
{
_reader
?.
stopContinuousDecode
();
controller
.
close
();
};
return
controller
.
stream
;
controller
!.
onCancel
=
()
=>
stopDetectBarcodeContinuously
();
return
controller
!.
stream
;
}
@override
...
...
Please
register
or
login
to post a comment