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-04-16 15:46:55 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dc119f73aad4540dd49f42010d1a70fe1948ef41
dc119f73
1 parent
f31b03dc
fix missing JS annotations; use a switch expression; format
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
40 deletions
lib/src/web/zxing/result.dart
lib/src/web/zxing/result_point.dart
lib/src/web/zxing/zxing_barcode_reader.dart
lib/src/web/zxing/result.dart
View file @
dc119f7
...
...
@@ -10,6 +10,7 @@ import 'package:mobile_scanner/src/web/zxing/result_point.dart';
/// The JS static interop class for the Result class in the ZXing library.
///
/// See also: https://github.com/zxing-js/library/blob/master/src/core/Result.ts
@JS
()
extension
type
Result
(
JSObject
_
)
implements
JSObject
{
@JS
(
'barcodeFormat'
)
external
int
?
get
_barcodeFormat
;
...
...
@@ -30,48 +31,30 @@ extension type Result(JSObject _) implements JSObject {
///
/// See also https://github.com/zxing-js/library/blob/master/src/core/BarcodeFormat.ts
BarcodeFormat
get
barcodeFormat
{
switch
(
_barcodeFormat
)
{
case
0
:
return
BarcodeFormat
.
aztec
;
case
1
:
return
BarcodeFormat
.
codabar
;
case
2
:
return
BarcodeFormat
.
code39
;
case
3
:
return
BarcodeFormat
.
code93
;
case
4
:
return
BarcodeFormat
.
code128
;
case
5
:
return
BarcodeFormat
.
dataMatrix
;
case
6
:
return
BarcodeFormat
.
ean8
;
case
7
:
return
BarcodeFormat
.
ean13
;
case
8
:
return
BarcodeFormat
.
itf
;
case
9
:
return
switch
(
_barcodeFormat
)
{
0
=>
BarcodeFormat
.
aztec
,
1
=>
BarcodeFormat
.
codabar
,
2
=>
BarcodeFormat
.
code39
,
3
=>
BarcodeFormat
.
code93
,
4
=>
BarcodeFormat
.
code128
,
5
=>
BarcodeFormat
.
dataMatrix
,
6
=>
BarcodeFormat
.
ean8
,
7
=>
BarcodeFormat
.
ean13
,
8
=>
BarcodeFormat
.
itf
,
// Maxicode
return
BarcodeFormat
.
unknown
;
case
10
:
return
BarcodeFormat
.
pdf417
;
case
11
:
return
BarcodeFormat
.
qrCode
;
case
12
:
9
=>
BarcodeFormat
.
unknown
,
10
=>
BarcodeFormat
.
pdf417
,
11
=>
BarcodeFormat
.
qrCode
,
// RSS 14
return
BarcodeFormat
.
unknown
;
case
13
:
12
=>
BarcodeFormat
.
unknown
,
// RSS EXPANDED
return
BarcodeFormat
.
unknown
;
case
14
:
return
BarcodeFormat
.
upcA
;
case
15
:
return
BarcodeFormat
.
upcE
;
case
16
:
13
=>
BarcodeFormat
.
unknown
,
14
=>
BarcodeFormat
.
upcA
,
15
=>
BarcodeFormat
.
upcE
,
// UPC/EAN extension
return
BarcodeFormat
.
unknown
;
default
:
return
BarcodeFormat
.
unknown
;
}
16
=>
BarcodeFormat
.
unknown
,
_
=>
BarcodeFormat
.
unknown
};
}
/// Get the raw bytes of the result.
...
...
lib/src/web/zxing/result_point.dart
View file @
dc119f7
...
...
@@ -3,6 +3,7 @@ import 'dart:js_interop';
/// The JS static interop class for the Result class in the ZXing library.
///
/// See also: https://github.com/zxing-js/library/blob/master/src/core/ResultPoint.ts
@JS
()
extension
type
ResultPoint
(
JSObject
_
)
implements
JSObject
{
/// The x coordinate of the point.
external
double
get
x
;
...
...
lib/src/web/zxing/zxing_barcode_reader.dart
View file @
dc119f7
...
...
@@ -165,7 +165,8 @@ final class ZXingBarcodeReader extends BarcodeReader {
extension
on
BarcodeFormat
{
/// Get the barcode format from the ZXing library.
JSNumber
get
toJS
=>
switch
(
this
)
{
JSNumber
get
toJS
{
final
int
zxingFormat
=
switch
(
this
)
{
BarcodeFormat
.
aztec
=>
0
,
BarcodeFormat
.
codabar
=>
1
,
BarcodeFormat
.
code39
=>
2
,
...
...
@@ -180,6 +181,8 @@ extension on BarcodeFormat {
BarcodeFormat
.
upcA
=>
14
,
BarcodeFormat
.
upcE
=>
15
,
BarcodeFormat
.
unknown
||
BarcodeFormat
.
all
||
_
=>
-
1
,
};
return
zxingFormat
.
toJS
;
}
.
toJS
;
}
...
...
Please
register
or
login
to post a comment