David PHAM-VAN

Fix BarcodeWidget positioning

# Changelog
## 1.3.30
## 1.4.0
- Improve BarcodeWidget
- Fix BarcodeWidget positioning
- Update dependency to barcode ^1.4.0
## 1.3.29
... ...
... ... @@ -61,7 +61,7 @@ class _BarcodeWidget extends Widget {
if (element.black) {
context.canvas.drawRect(
box.left + element.left,
box.top + element.top - element.height,
box.top - element.top - element.height,
element.width,
element.height,
);
... ... @@ -81,15 +81,28 @@ class _BarcodeWidget extends Widget {
for (BarcodeText text in textList) {
final PdfFontMetrics metrics = font.stringMetrics(text.text);
final double left = text.left +
box.left +
(text.width - metrics.width * text.height) / 2;
final double top = box.top -
text.top -
metrics.descent * textStyle.fontSize -
text.height;
double left;
switch (text.align) {
case BarcodeTextAlign.left:
left = text.left + box.left;
break;
case BarcodeTextAlign.center:
left = text.left +
box.left +
(text.width - metrics.width * text.height) / 2;
break;
case BarcodeTextAlign.right:
left = text.left +
box.left +
(text.width - metrics.width * text.height);
break;
}
context.canvas
..setFillColor(textStyle.color)
..drawString(
... ...
... ... @@ -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.30
version: 1.4.0
environment:
sdk: ">=2.3.0 <3.0.0"
... ... @@ -16,7 +16,7 @@ dependencies:
crypto: ^2.0.6
archive: ^2.0.10
qr: ^1.2.0
barcode: ^1.0.0
barcode: ^1.4.0
dev_dependencies:
test:
... ...
... ... @@ -44,7 +44,7 @@ Widget barcode(Barcode barcode, String data) {
height: 80,
margin: const EdgeInsets.symmetric(vertical: 20),
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 3),
decoration: BoxDecoration(
decoration: const BoxDecoration(
border: BoxBorder(
color: PdfColors.blue,
top: true,
... ... @@ -93,7 +93,7 @@ void main() {
decoration: BoxDecoration(
borderRadius: 20,
color: PdfColors.white,
border: BoxBorder(
border: const BoxBorder(
color: PdfColors.blue,
top: true,
bottom: true,
... ...