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-26 09:26:38 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7643054eb34f58bc64e808cad9fdc2d46e09dc98
7643054e
1 parent
2328edc2
bump to pkg:web 0.4.2 and add workaround for JSAny implements
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
lib/src/web/zxing/zxing_barcode_reader.dart
pubspec.yaml
lib/src/web/zxing/zxing_barcode_reader.dart
View file @
7643054
...
...
@@ -14,6 +14,8 @@ import 'package:mobile_scanner/src/web/zxing/result.dart';
import
'package:mobile_scanner/src/web/zxing/zxing_browser_multi_format_reader.dart'
;
import
'package:web/web.dart'
as
web
;
// TODO: remove the JSAny casts once upgraded to a package:web version that restores "implements JSAny"
/// A barcode reader implementation that uses the ZXing library.
final
class
ZXingBarcodeReader
extends
BarcodeReader
{
ZXingBarcodeReader
();
...
...
@@ -110,7 +112,7 @@ final class ZXingBarcodeReader extends BarcodeReader {
Future
<
web
.
MediaStream
?>
_prepareMediaStream
(
CameraFacing
cameraDirection
,
)
async
{
if
(
web
.
window
.
navigator
.
mediaDevices
.
isUndefinedOrNull
)
{
if
(
(
web
.
window
.
navigator
.
mediaDevices
as
JSAny
?)
.
isUndefinedOrNull
)
{
return
null
;
}
...
...
@@ -119,7 +121,7 @@ final class ZXingBarcodeReader extends BarcodeReader {
final
web
.
MediaStreamConstraints
constraints
;
if
(
capabilities
.
isUndefinedOrNull
||
!
capabilities
.
facingMode
)
{
if
(
(
capabilities
as
JSAny
)
.
isUndefinedOrNull
||
!
capabilities
.
facingMode
)
{
constraints
=
web
.
MediaStreamConstraints
(
video:
true
.
toJS
);
}
else
{
final
String
facingMode
=
switch
(
cameraDirection
)
{
...
...
@@ -130,7 +132,7 @@ final class ZXingBarcodeReader extends BarcodeReader {
constraints
=
web
.
MediaStreamConstraints
(
video:
web
.
MediaTrackConstraintSet
(
facingMode:
facingMode
.
toJS
,
),
)
as
JSAny
,
);
}
...
...
@@ -159,8 +161,11 @@ final class ZXingBarcodeReader extends BarcodeReader {
final
web
.
MediaStream
?
stream
=
await
_prepareMediaStream
(
cameraDirection
);
if
(
stream
!=
null
)
{
final
JSPromise
?
result
=
_reader
?.
attachStreamToVideo
.
callAsFunction
(
null
,
stream
,
videoElement
)
as
JSPromise
?;
final
JSPromise
?
result
=
_reader
?.
attachStreamToVideo
.
callAsFunction
(
null
,
stream
as
JSAny
,
videoElement
as
JSAny
,
)
as
JSPromise
?;
await
result
?.
toDart
;
...
...
@@ -180,7 +185,7 @@ final class ZXingBarcodeReader extends BarcodeReader {
controller
.
onListen
=
()
{
_reader
?.
decodeContinuously
.
callAsFunction
(
null
,
_reader
?.
videoElement
,
_reader
?.
videoElement
as
JSAny
?
,
(
Result
?
result
,
JSAny
?
error
)
{
if
(!
controller
.
isClosed
&&
result
!=
null
)
{
controller
.
add
(
...
...
pubspec.yaml
View file @
7643054
...
...
@@ -25,7 +25,7 @@ dependencies:
flutter_web_plugins
:
sdk
:
flutter
plugin_platform_interface
:
^2.0.2
web
:
^0.
3.0
web
:
^0.
4.2
dev_dependencies
:
flutter_test
:
...
...
Please
register
or
login
to post a comment