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
2019-12-29 12:27:08 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b6e6ae2c4329eaab262d65d3afa3cafb0beb7c1e
b6e6ae2c
1 parent
b94f15d5
Improve BarcodeWidget
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
44 deletions
pdf/CHANGELOG.md
pdf/lib/widgets/barcode.dart
pdf/pubspec.yaml
pdf/test/widget_barcode_test.dart
test/golden/widgets-barcode.pdf
pdf/CHANGELOG.md
View file @
b6e6ae2
# Changelog
## 1.3.30
-
Improve BarcodeWidget
## 1.3.29
-
Use Barcode stable API
...
...
pdf/lib/widgets/barcode.dart
View file @
b6e6ae2
...
...
@@ -136,7 +136,9 @@ class _BarcodeWidget extends Widget {
class
BarcodeWidget
extends
StatelessWidget
{
BarcodeWidget
({
@required
this
.
data
,
this
.
type
=
BarcodeType
.
Code39
,
@Deprecated
(
'Use `Barcode.fromType(type)` instead'
)
BarcodeType
type
=
BarcodeType
.
Code39
,
Barcode
barcode
,
this
.
color
=
PdfColors
.
black
,
this
.
backgroundColor
,
this
.
decoration
,
...
...
@@ -146,12 +148,14 @@ class BarcodeWidget extends StatelessWidget {
this
.
height
,
this
.
drawText
=
true
,
this
.
textStyle
,
});
})
:
// ignore: deprecated_member_use_from_same_package
barcode
=
barcode
??
Barcode
.
fromType
(
type
);
/// the barcode data
final
String
data
;
final
Barcode
Type
typ
e
;
final
Barcode
barcod
e
;
final
PdfColor
color
;
...
...
@@ -183,38 +187,38 @@ class BarcodeWidget extends StatelessWidget {
);
final
TextStyle
_textStyle
=
defaultstyle
.
merge
(
textStyle
);
Widget
barcode
=
_BarcodeWidget
(
Widget
child
=
_BarcodeWidget
(
data:
data
,
color:
color
,
barcode:
Barcode
.
fromType
(
type
)
,
barcode:
barcode
,
drawText:
drawText
,
textStyle:
_textStyle
,
);
if
(
padding
!=
null
)
{
barcode
=
Padding
(
padding:
padding
,
child:
barcode
);
child
=
Padding
(
padding:
padding
,
child:
child
);
}
if
(
decoration
!=
null
)
{
barcode
=
DecoratedBox
(
child
=
DecoratedBox
(
decoration:
decoration
,
child:
barcode
,
child:
child
,
);
}
else
if
(
backgroundColor
!=
null
)
{
barcode
=
DecoratedBox
(
child
=
DecoratedBox
(
decoration:
BoxDecoration
(
color:
backgroundColor
),
child:
barcode
,
child:
child
,
);
}
if
(
width
!=
null
||
height
!=
null
)
{
barcode
=
SizedBox
(
width:
width
,
height:
height
,
child:
barcode
);
child
=
SizedBox
(
width:
width
,
height:
height
,
child:
child
);
}
if
(
margin
!=
null
)
{
barcode
=
Padding
(
padding:
margin
,
child:
barcode
);
child
=
Padding
(
padding:
margin
,
child:
child
);
}
return
barcode
;
return
child
;
}
}
...
...
pdf/pubspec.yaml
View file @
b6e6ae2
...
...
@@ -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.3.
29
version
:
1.3.
30
environment
:
sdk
:
"
>=2.3.0
<3.0.0"
...
...
pdf/test/widget_barcode_test.dart
View file @
b6e6ae2
...
...
@@ -25,6 +25,40 @@ import 'package:test/test.dart';
Document
pdf
;
Widget
barcode
(
Barcode
barcode
,
String
data
)
{
return
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
<
Widget
>[
Flexible
(
fit:
FlexFit
.
tight
,
child:
Center
(
child:
Text
(
barcode
.
name
),
),
),
Flexible
(
fit:
FlexFit
.
tight
,
child:
BarcodeWidget
(
barcode:
barcode
,
data:
data
,
width:
200
,
height:
80
,
margin:
const
EdgeInsets
.
symmetric
(
vertical:
20
),
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
10
,
vertical:
3
),
decoration:
BoxDecoration
(
border:
BoxBorder
(
color:
PdfColors
.
blue
,
top:
true
,
bottom:
true
,
left:
true
,
right:
true
,
),
),
),
),
],
);
}
void
main
(
)
{
setUpAll
(()
{
Document
.
debug
=
true
;
...
...
@@ -34,34 +68,16 @@ void main() {
test
(
'Barcode Widgets'
,
()
{
pdf
.
addPage
(
MultiPage
(
build:
(
Context
context
)
=>
List
<
Widget
>.
generate
(
BarcodeType
.
values
.
length
,
(
int
index
)
{
return
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
<
Widget
>[
Text
(
BarcodeType
.
values
[
index
].
toString
()),
BarcodeWidget
(
type:
BarcodeType
.
values
[
index
],
data:
'HELLO 123'
,
width:
200
,
height:
50
,
margin:
const
EdgeInsets
.
symmetric
(
vertical:
20
),
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
10
,
vertical:
3
),
decoration:
BoxDecoration
(
border:
BoxBorder
(
color:
PdfColors
.
blue
,
top:
true
,
bottom:
true
,
left:
true
,
right:
true
,
)),
),
],
);
},
),
build:
(
Context
context
)
=>
<
Widget
>[
barcode
(
Barcode
.
code39
(),
'CODE 39'
),
barcode
(
Barcode
.
code93
(),
'CODE 93'
),
barcode
(
Barcode
.
code128
(),
'Barcode 128'
),
barcode
(
Barcode
.
ean13
(),
'590123412345'
),
barcode
(
Barcode
.
ean8
(),
'9638507'
),
barcode
(
Barcode
.
isbn
(),
'978316148410'
),
barcode
(
Barcode
.
upcA
(),
'98765432109'
),
barcode
(
Barcode
.
upcE
(),
'06510000432'
),
],
),
);
});
...
...
test/golden/widgets-barcode.pdf
View file @
b6e6ae2
No preview for this file type
Please
register
or
login
to post a comment