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 22:16:30 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
18da618fb5c58c31e7d1fb126bb0f8ee6d7b22ca
18da618f
1 parent
bafacb5d
bug: fix pause and resume not working on web
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
8 deletions
lib/src/web/barcode_reader.dart
lib/src/web/mobile_scanner_web.dart
lib/src/web/zxing/zxing_barcode_reader.dart
lib/src/web/barcode_reader.dart
View file @
18da618
...
...
@@ -13,6 +13,17 @@ import 'package:web/web.dart';
abstract
class
BarcodeReader
{
const
BarcodeReader
();
/// Whether the video feed is paused
bool
?
get
paused
=>
throw
UnimplementedError
(
'paused has not been implemented.'
);
/// Pause the barcode reader.
void
pause
()
=>
throw
UnimplementedError
(
'pause() has not been implemented.'
);
/// Pause the barcode reader.
Future
<
void
>
resume
()
=>
throw
UnimplementedError
(
'resume() has not been implemented.'
);
/// Whether the scanner is currently scanning for barcodes.
bool
get
isScanning
{
throw
UnimplementedError
(
'isScanning has not been implemented.'
);
...
...
@@ -128,11 +139,6 @@ abstract class BarcodeReader {
throw
UnimplementedError
(
'start() has not been implemented.'
);
}
/// Pause the barcode reader.
Future
<
void
>
pause
()
{
throw
UnimplementedError
(
'pause() has not been implemented.'
);
}
/// Stop the barcode reader and dispose of the video stream.
Future
<
void
>
stop
()
{
throw
UnimplementedError
(
'stop() has not been implemented.'
);
...
...
lib/src/web/mobile_scanner_web.dart
View file @
18da618
...
...
@@ -263,6 +263,16 @@ class MobileScannerWeb extends MobileScannerPlatform {
@override
Future
<
MobileScannerViewAttributes
>
start
(
StartOptions
startOptions
)
async
{
if
(
_barcodeReader
!=
null
)
{
if
(
_barcodeReader
!.
paused
??
false
)
{
await
_barcodeReader
?.
resume
();
return
MobileScannerViewAttributes
(
// The torch of a media stream is not available for video tracks.
// See https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#instance_properties_of_video_tracks
currentTorchMode:
TorchState
.
unavailable
,
size:
_barcodeReader
?.
videoSize
??
Size
.
zero
,
);
}
throw
const
MobileScannerException
(
errorCode:
MobileScannerErrorCode
.
controllerAlreadyInitialized
,
errorDetails:
MobileScannerErrorDetails
(
...
...
@@ -365,7 +375,7 @@ class MobileScannerWeb extends MobileScannerPlatform {
@override
Future
<
void
>
pause
()
async
{
_barcodesSubscription
?.
pause
();
await
_barcodeReader
?.
pause
();
_barcodeReader
?.
pause
();
}
@override
...
...
lib/src/web/zxing/zxing_barcode_reader.dart
View file @
18da618
...
...
@@ -169,8 +169,15 @@ final class ZXingBarcodeReader extends BarcodeReader {
}
@override
Future
<
void
>
pause
()
async
{
_reader
?.
videoElement
?.
pause
();
bool
?
get
paused
=>
_reader
?.
videoElement
?.
paused
;
@override
void
pause
()
=>
_reader
?.
videoElement
?.
pause
();
@override
Future
<
void
>
resume
()
async
{
final
result
=
_reader
?.
videoElement
?.
play
();
await
result
?.
toDart
;
}
@override
...
...
Please
register
or
login
to post a comment