Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
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
David PHAM-VAN
2022-08-23 07:25:15 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8d4af765fd7cb663c2dac9016be54740c9b78d83
8d4af765
1 parent
f353a29f
Bump barcode dependency to 2.2.3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
60 deletions
pdf/CHANGELOG.md
pdf/lib/src/widgets/barcode.dart
pdf/pubspec.yaml
pdf/CHANGELOG.md
View file @
8d4af76
...
...
@@ -3,6 +3,8 @@
## 3.8.3
-
Fix Arabic TextAlign.justify issues Set default text align based on text direction
[
Milad akarie
]
-
Bump barcode dependency to 2.2.3
## 3.8.2
-
Fix Compressed Cross-Reference ID
...
...
pdf/lib/src/widgets/barcode.dart
View file @
8d4af76
...
...
@@ -30,17 +30,19 @@ import 'theme.dart';
import
'widget.dart'
;
class
_BarcodeWidget
extends
Widget
{
_BarcodeWidget
({
required
this
.
data
,
_BarcodeWidget
(
this
.
dataBytes
,
this
.
dataString
,
this
.
barcode
,
this
.
color
=
PdfColors
.
black
,
this
.
color
,
this
.
drawText
,
this
.
textStyle
,
this
.
textPadding
,
}
);
);
/// the barcode data
final
Uint8List
data
;
final
String
?
dataString
;
final
Uint8List
?
dataBytes
;
final
Barcode
?
barcode
;
...
...
@@ -58,20 +60,31 @@ class _BarcodeWidget extends Widget {
box
=
PdfRect
.
fromPoints
(
PdfPoint
.
zero
,
constraints
.
biggest
);
}
Iterable
<
BarcodeElement
>
get
barcodeDraw
=>
dataBytes
!=
null
?
barcode
!.
makeBytes
(
dataBytes
!,
width:
box
!.
width
,
height:
box
!.
height
,
drawText:
drawText
!,
fontHeight:
textStyle
!.
fontSize
!,
textPadding:
textPadding
!,
)
:
barcode
!.
make
(
dataString
!,
width:
box
!.
width
,
height:
box
!.
height
,
drawText:
drawText
!,
fontHeight:
textStyle
!.
fontSize
!,
textPadding:
textPadding
!,
);
@override
void
paint
(
Context
context
)
{
super
.
paint
(
context
);
final
textList
=
<
BarcodeText
>[];
for
(
final
element
in
barcode
!.
makeBytes
(
data
,
width:
box
!.
width
,
height:
box
!.
height
,
drawText:
drawText
!,
fontHeight:
textStyle
!.
fontSize
!,
textPadding:
textPadding
!,
))
{
for
(
final
element
in
barcodeDraw
)
{
if
(
element
is
BarcodeBar
)
{
if
(
element
.
black
)
{
context
.
canvas
.
drawRect
(
...
...
@@ -136,14 +149,7 @@ class _BarcodeWidget extends Widget {
super
.
debugPaint
(
context
);
if
(
drawText
!)
{
for
(
final
element
in
barcode
!.
makeBytes
(
data
,
width:
box
!.
width
,
height:
box
!.
height
,
drawText:
drawText
!,
fontHeight:
textStyle
!.
fontSize
!,
textPadding:
textPadding
!,
))
{
for
(
final
element
in
barcodeDraw
)
{
if
(
element
is
BarcodeText
)
{
context
.
canvas
.
drawRect
(
box
!.
x
+
element
.
left
,
...
...
@@ -165,38 +171,25 @@ class _BarcodeWidget extends Widget {
/// Draw a barcode using String data
class
BarcodeWidget
extends
StatelessWidget
{
/// Create a BarcodeWidget
factory
BarcodeWidget
({
BarcodeWidget
({
required
String
data
,
required
Barcode
barcode
,
PdfColor
color
=
PdfColors
.
black
,
PdfColor
?
backgroundColor
,
BoxDecoration
?
decoration
,
EdgeInsets
?
margin
,
EdgeInsets
?
padding
,
double
?
width
,
double
?
height
,
bool
drawText
=
true
,
TextStyle
?
textStyle
,
double
textPadding
=
0
,
})
=>
BarcodeWidget
.
fromBytes
(
data:
utf8
.
encoder
.
convert
(
data
),
barcode:
barcode
,
color:
color
,
backgroundColor:
backgroundColor
,
decoration:
decoration
,
margin:
margin
,
padding:
padding
,
width:
width
,
height:
height
,
drawText:
drawText
,
textStyle:
textStyle
,
textPadding:
textPadding
,
);
required
this
.
barcode
,
this
.
color
=
PdfColors
.
black
,
this
.
backgroundColor
,
this
.
decoration
,
this
.
margin
,
this
.
padding
,
this
.
width
,
this
.
height
,
this
.
drawText
=
true
,
this
.
textStyle
,
this
.
textPadding
=
0
,
})
:
dataBytes
=
null
,
dataString
=
data
;
/// Draw a barcode using Uint8List data
BarcodeWidget
.
fromBytes
({
required
this
.
data
,
required
Uint8List
data
,
required
this
.
barcode
,
this
.
color
=
PdfColors
.
black
,
this
.
backgroundColor
,
...
...
@@ -208,10 +201,14 @@ class BarcodeWidget extends StatelessWidget {
this
.
drawText
=
true
,
this
.
textStyle
,
this
.
textPadding
=
0
,
});
})
:
dataBytes
=
data
,
dataString
=
null
;
/// the barcode data
final
Uint8List
data
;
final
String
?
dataString
;
final
Uint8List
?
dataBytes
;
Uint8List
get
data
=>
dataBytes
??
Uint8List
.
fromList
(
utf8
.
encode
(
dataString
!));
/// The type of barcode to use.
/// use:
...
...
@@ -254,7 +251,7 @@ class BarcodeWidget extends StatelessWidget {
@override
Widget
build
(
Context
context
)
{
final
default
s
tyle
=
Theme
.
of
(
context
).
defaultTextStyle
.
copyWith
(
final
default
S
tyle
=
Theme
.
of
(
context
).
defaultTextStyle
.
copyWith
(
font:
Font
.
courier
(),
fontNormal:
Font
.
courier
(),
fontBold:
Font
.
courierBold
(),
...
...
@@ -263,15 +260,16 @@ class BarcodeWidget extends StatelessWidget {
lineSpacing:
1
,
fontSize:
height
!=
null
?
height
!
*
0.2
:
null
,
);
final
_textStyle
=
default
s
tyle
.
merge
(
textStyle
);
final
_textStyle
=
default
S
tyle
.
merge
(
textStyle
);
Widget
child
=
_BarcodeWidget
(
data:
data
,
color:
color
,
barcode:
barcode
,
drawText:
drawText
,
textStyle:
_textStyle
,
textPadding:
textPadding
,
dataBytes
,
dataString
,
barcode
,
color
,
drawText
,
_textStyle
,
textPadding
,
);
if
(
padding
!=
null
)
{
...
...
pdf/pubspec.yaml
View file @
8d4af76
...
...
@@ -10,7 +10,7 @@ environment:
dependencies
:
archive
:
^3.1.0
barcode
:
"
>=2.2.
0
<3.0.0"
barcode
:
"
>=2.2.
3
<3.0.0"
crypto
:
^3.0.0
image
:
"
>=3.0.1
<4.0.0"
meta
:
"
>=1.3.0
<2.0.0"
...
...
Please
register
or
login
to post a comment