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-09-10 10:19:59 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6d904181a79b6b202ff678f72c6c18732cecac6c
6d904181
1 parent
a971a181
compute the size for web barcodes
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
lib/src/objects/barcode.dart
lib/src/web/zxing/result.dart
lib/src/objects/barcode.dart
View file @
6d90418
...
...
@@ -152,7 +152,7 @@ class Barcode {
/// This is null if the raw value is not available.
final
String
?
rawValue
;
/// The size of the barcode bounding box.
/// The
normalized
size of the barcode bounding box.
///
/// If the bounding box is unavailable, this will be [Size.zero].
final
Size
size
;
...
...
lib/src/web/zxing/result.dart
View file @
6d90418
...
...
@@ -75,13 +75,33 @@ extension type Result(JSObject _) implements JSObject {
/// Convert this result to a [Barcode].
Barcode
get
toBarcode
{
final
List
<
Offset
>
corners
=
resultPoints
;
return
Barcode
(
corners:
resultPoint
s
,
corners:
corner
s
,
format:
barcodeFormat
,
displayValue:
text
,
rawBytes:
rawBytes
,
rawValue:
text
,
size:
_computeSize
(
corners
),
type:
BarcodeType
.
text
,
);
}
Size
_computeSize
(
List
<
Offset
>
points
)
{
if
(
points
.
length
!=
4
)
{
return
Size
.
zero
;
}
final
Iterable
<
double
>
xCoords
=
points
.
map
((
p
)
=>
p
.
dx
);
final
Iterable
<
double
>
yCoords
=
points
.
map
((
p
)
=>
p
.
dy
);
// Find the minimum and maximum x and y coordinates.
final
double
xMin
=
xCoords
.
reduce
((
a
,
b
)
=>
a
<
b
?
a
:
b
);
final
double
xMax
=
xCoords
.
reduce
((
a
,
b
)
=>
a
>
b
?
a
:
b
);
final
double
yMin
=
yCoords
.
reduce
((
a
,
b
)
=>
a
<
b
?
a
:
b
);
final
double
yMax
=
yCoords
.
reduce
((
a
,
b
)
=>
a
>
b
?
a
:
b
);
return
Size
(
xMax
-
xMin
,
yMax
-
yMin
);
}
}
...
...
Please
register
or
login
to post a comment