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
2023-06-30 10:21:45 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6582f612307c2ffe8fed20eeb8c992d94ad6a5e4
6582f612
1 parent
6c550754
add zxing corners to web barcode
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
0 deletions
lib/mobile_scanner_web_plugin.dart
lib/src/mobile_scanner_controller.dart
lib/src/web/zxing.dart
lib/mobile_scanner_web_plugin.dart
View file @
6582f61
...
...
@@ -130,12 +130,22 @@ class MobileScannerWebPlugin {
_barCodeStreamSubscription
=
barCodeReader
.
detectBarcodeContinuously
().
listen
((
code
)
{
if
(
code
!=
null
)
{
final
List
<
Offset
>?
corners
=
code
.
corners
;
controller
.
add
({
'name'
:
'barcodeWeb'
,
'data'
:
{
'rawValue'
:
code
.
rawValue
,
'rawBytes'
:
code
.
rawBytes
,
'format'
:
code
.
format
.
rawValue
,
'displayValue'
:
code
.
displayValue
,
'type'
:
code
.
type
.
index
,
if
(
corners
!=
null
&&
corners
.
isNotEmpty
)
'corners'
:
corners
.
map
(
(
Offset
c
)
=>
<
Object
?,
Object
?>{
'x'
:
c
.
dx
,
'y'
:
c
.
dy
},
)
.
toList
(),
},
});
}
...
...
lib/src/mobile_scanner_controller.dart
View file @
6582f61
...
...
@@ -400,6 +400,10 @@ class MobileScannerController {
rawValue:
barcode
[
'rawValue'
]
as
String
?,
rawBytes:
barcode
[
'rawBytes'
]
as
Uint8List
?,
format:
toFormat
(
barcode
[
'format'
]
as
int
),
corners:
toCorners
(
(
barcode
[
'corners'
]
as
List
<
Object
?>?
??
[])
.
cast
<
Map
<
Object
?,
Object
?>>(),
),
),
],
),
...
...
lib/src/web/zxing.dart
View file @
6582f61
import
'dart:async'
;
import
'dart:html'
;
import
'dart:typed_data'
;
import
'dart:ui'
;
import
'package:js/js.dart'
;
import
'package:mobile_scanner/src/enums/camera_facing.dart'
;
...
...
@@ -19,6 +20,16 @@ class JsZXingBrowserMultiFormatReader {
@JS
()
@anonymous
abstract
class
ResultPoint
{
/// The x coordinate of the point.
external
double
get
x
;
/// The y coordinate of the point.
external
double
get
y
;
}
@JS
()
@anonymous
abstract
class
Result
{
/// raw text encoded by the barcode
external
String
get
text
;
...
...
@@ -28,15 +39,24 @@ abstract class Result {
/// Representing the format of the barcode that was decoded
external
int
?
format
;
/// Returns the result points of the barcode. These points represent the corners of the barcode.
external
List
<
Object
?>
get
resultPoints
;
}
extension
ResultExt
on
Result
{
Barcode
toBarcode
()
{
final
corners
=
resultPoints
.
cast
<
ResultPoint
>()
.
map
((
ResultPoint
rp
)
=>
Offset
(
rp
.
x
,
rp
.
y
))
.
toList
();
final
rawBytes
=
this
.
rawBytes
;
return
Barcode
(
rawValue:
text
,
rawBytes:
rawBytes
!=
null
?
Uint8List
.
fromList
(
rawBytes
)
:
null
,
format:
barcodeFormat
,
corners:
corners
,
);
}
...
...
Please
register
or
login
to post a comment