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
2020-08-01 12:51:49 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
efad4498f40292312375760c218c428c5016cfbe
efad4498
1 parent
cc48f97a
Implement Barcode textPadding and bytes data
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
11 deletions
pdf/CHANGELOG.md
pdf/lib/widgets.dart
pdf/lib/widgets/barcode.dart
pdf/pubspec.yaml
pdf/CHANGELOG.md
View file @
efad449
# Changelog
## 1.
9.1
## 1.
10.0
-
Fix dependency to Image
-
Fix dependencies
-
Implement Barcode textPadding and bytes data
## 1.9.0
...
...
pdf/lib/widgets.dart
View file @
efad449
...
...
@@ -17,6 +17,7 @@
library
widget
;
import
'dart:collection'
;
import
'dart:convert'
;
import
'dart:math'
as
math
;
import
'dart:typed_data'
;
import
'package:image/image.dart'
as
im
;
...
...
pdf/lib/widgets/barcode.dart
View file @
efad449
...
...
@@ -25,10 +25,11 @@ class _BarcodeWidget extends Widget {
this
.
color
=
PdfColors
.
black
,
this
.
drawText
,
this
.
textStyle
,
this
.
textPadding
,
});
/// the barcode data
final
String
data
;
final
Uint8List
data
;
final
Barcode
barcode
;
...
...
@@ -38,6 +39,8 @@ class _BarcodeWidget extends Widget {
final
TextStyle
textStyle
;
final
double
textPadding
;
@override
void
layout
(
Context
context
,
BoxConstraints
constraints
,
{
bool
parentUsesSize
=
false
})
{
...
...
@@ -50,12 +53,13 @@ class _BarcodeWidget extends Widget {
final
List
<
BarcodeText
>
textList
=
<
BarcodeText
>[];
for
(
BarcodeElement
element
in
barcode
.
make
(
for
(
BarcodeElement
element
in
barcode
.
make
Bytes
(
data
,
width:
box
.
width
,
height:
box
.
height
,
drawText:
drawText
,
fontHeight:
textStyle
.
fontSize
,
textPadding:
textPadding
,
))
{
if
(
element
is
BarcodeBar
)
{
if
(
element
.
black
)
{
...
...
@@ -121,12 +125,13 @@ class _BarcodeWidget extends Widget {
super
.
debugPaint
(
context
);
if
(
drawText
)
{
for
(
BarcodeElement
element
in
barcode
.
make
(
for
(
BarcodeElement
element
in
barcode
.
make
Bytes
(
data
,
width:
box
.
width
,
height:
box
.
height
,
drawText:
drawText
,
fontHeight:
textStyle
.
fontSize
,
textPadding:
textPadding
,
))
{
if
(
element
is
BarcodeText
)
{
context
.
canvas
.
drawRect
(
...
...
@@ -147,7 +152,38 @@ class _BarcodeWidget extends Widget {
}
class
BarcodeWidget
extends
StatelessWidget
{
BarcodeWidget
({
/// Draw a barcode using String data
factory
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
,
);
/// Draw a barcode using Uint8List data
BarcodeWidget
.
fromBytes
({
@required
this
.
data
,
@required
this
.
barcode
,
this
.
color
=
PdfColors
.
black
,
...
...
@@ -159,29 +195,51 @@ class BarcodeWidget extends StatelessWidget {
this
.
height
,
this
.
drawText
=
true
,
this
.
textStyle
,
})
:
assert
(
barcode
!=
null
);
this
.
textPadding
=
0
,
})
:
assert
(
data
!=
null
),
assert
(
barcode
!=
null
),
assert
(
textPadding
!=
null
);
/// the barcode data
final
String
data
;
final
Uint8List
data
;
/// The type of barcode to use.
/// use:
/// * Barcode.code128()
/// * Barcode.ean13()
/// * ...
final
Barcode
barcode
;
/// The bars color
/// should be black or really dark color
final
PdfColor
color
;
/// The background color.
/// this should be white or really light color
final
PdfColor
backgroundColor
;
/// Padding to apply
final
EdgeInsets
padding
;
/// Margin to apply
final
EdgeInsets
margin
;
/// Width of the barcode with padding
final
double
width
;
/// Height of the barcode with padding
final
double
height
;
/// Whether to draw the text with the barcode
final
bool
drawText
;
/// Text style to use to draw the text
final
TextStyle
textStyle
;
/// Padding to add between the text and the barcode
final
double
textPadding
;
/// Decoration to apply to the barcode
final
BoxDecoration
decoration
;
@override
...
...
@@ -203,6 +261,7 @@ class BarcodeWidget extends StatelessWidget {
barcode:
barcode
,
drawText:
drawText
,
textStyle:
_textStyle
,
textPadding:
textPadding
,
);
if
(
padding
!=
null
)
{
...
...
pdf/pubspec.yaml
View file @
efad449
...
...
@@ -4,7 +4,7 @@ description: A pdf producer for Dart. It can create pdf files for both web or fl
homepage
:
https://github.com/DavBfr/dart_pdf/tree/master/pdf
repository
:
https://github.com/DavBfr/dart_pdf
issue_tracker
:
https://github.com/DavBfr/dart_pdf/issues
version
:
1.
9.1
version
:
1.
10.0
environment
:
sdk
:
"
>=2.3.0
<3.0.0"
...
...
@@ -15,10 +15,10 @@ dependencies:
utf
:
^0.9.0
crypto
:
^2.0.6
archive
:
^2.0.10
barcode
:
^1.1
4
.0
barcode
:
^1.1
6
.0
image
:
^2.1.10
path_parsing
:
^0.1.4
dev_dependencies
:
test
:
pedantic
:
1.9.
0
pedantic
:
1.9.
2
...
...
Please
register
or
login
to post a comment