Showing
5 changed files
with
27 additions
and
12 deletions
| @@ -61,7 +61,7 @@ class _BarcodeWidget extends Widget { | @@ -61,7 +61,7 @@ class _BarcodeWidget extends Widget { | ||
| 61 | if (element.black) { | 61 | if (element.black) { |
| 62 | context.canvas.drawRect( | 62 | context.canvas.drawRect( |
| 63 | box.left + element.left, | 63 | box.left + element.left, |
| 64 | - box.top + element.top - element.height, | 64 | + box.top - element.top - element.height, |
| 65 | element.width, | 65 | element.width, |
| 66 | element.height, | 66 | element.height, |
| 67 | ); | 67 | ); |
| @@ -81,15 +81,28 @@ class _BarcodeWidget extends Widget { | @@ -81,15 +81,28 @@ class _BarcodeWidget extends Widget { | ||
| 81 | for (BarcodeText text in textList) { | 81 | for (BarcodeText text in textList) { |
| 82 | final PdfFontMetrics metrics = font.stringMetrics(text.text); | 82 | final PdfFontMetrics metrics = font.stringMetrics(text.text); |
| 83 | 83 | ||
| 84 | - final double left = text.left + | ||
| 85 | - box.left + | ||
| 86 | - (text.width - metrics.width * text.height) / 2; | ||
| 87 | - | ||
| 88 | final double top = box.top - | 84 | final double top = box.top - |
| 89 | text.top - | 85 | text.top - |
| 90 | metrics.descent * textStyle.fontSize - | 86 | metrics.descent * textStyle.fontSize - |
| 91 | text.height; | 87 | text.height; |
| 92 | 88 | ||
| 89 | + double left; | ||
| 90 | + switch (text.align) { | ||
| 91 | + case BarcodeTextAlign.left: | ||
| 92 | + left = text.left + box.left; | ||
| 93 | + break; | ||
| 94 | + case BarcodeTextAlign.center: | ||
| 95 | + left = text.left + | ||
| 96 | + box.left + | ||
| 97 | + (text.width - metrics.width * text.height) / 2; | ||
| 98 | + break; | ||
| 99 | + case BarcodeTextAlign.right: | ||
| 100 | + left = text.left + | ||
| 101 | + box.left + | ||
| 102 | + (text.width - metrics.width * text.height); | ||
| 103 | + break; | ||
| 104 | + } | ||
| 105 | + | ||
| 93 | context.canvas | 106 | context.canvas |
| 94 | ..setFillColor(textStyle.color) | 107 | ..setFillColor(textStyle.color) |
| 95 | ..drawString( | 108 | ..drawString( |
| @@ -4,7 +4,7 @@ description: A pdf producer for Dart. It can create pdf files for both web or fl | @@ -4,7 +4,7 @@ description: A pdf producer for Dart. It can create pdf files for both web or fl | ||
| 4 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/pdf | 4 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/pdf |
| 5 | repository: https://github.com/DavBfr/dart_pdf | 5 | repository: https://github.com/DavBfr/dart_pdf |
| 6 | issue_tracker: https://github.com/DavBfr/dart_pdf/issues | 6 | issue_tracker: https://github.com/DavBfr/dart_pdf/issues |
| 7 | -version: 1.3.30 | 7 | +version: 1.4.0 |
| 8 | 8 | ||
| 9 | environment: | 9 | environment: |
| 10 | sdk: ">=2.3.0 <3.0.0" | 10 | sdk: ">=2.3.0 <3.0.0" |
| @@ -16,7 +16,7 @@ dependencies: | @@ -16,7 +16,7 @@ dependencies: | ||
| 16 | crypto: ^2.0.6 | 16 | crypto: ^2.0.6 |
| 17 | archive: ^2.0.10 | 17 | archive: ^2.0.10 |
| 18 | qr: ^1.2.0 | 18 | qr: ^1.2.0 |
| 19 | - barcode: ^1.0.0 | 19 | + barcode: ^1.4.0 |
| 20 | 20 | ||
| 21 | dev_dependencies: | 21 | dev_dependencies: |
| 22 | test: | 22 | test: |
| @@ -44,7 +44,7 @@ Widget barcode(Barcode barcode, String data) { | @@ -44,7 +44,7 @@ Widget barcode(Barcode barcode, String data) { | ||
| 44 | height: 80, | 44 | height: 80, |
| 45 | margin: const EdgeInsets.symmetric(vertical: 20), | 45 | margin: const EdgeInsets.symmetric(vertical: 20), |
| 46 | padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 3), | 46 | padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 3), |
| 47 | - decoration: BoxDecoration( | 47 | + decoration: const BoxDecoration( |
| 48 | border: BoxBorder( | 48 | border: BoxBorder( |
| 49 | color: PdfColors.blue, | 49 | color: PdfColors.blue, |
| 50 | top: true, | 50 | top: true, |
| @@ -93,7 +93,7 @@ void main() { | @@ -93,7 +93,7 @@ void main() { | ||
| 93 | decoration: BoxDecoration( | 93 | decoration: BoxDecoration( |
| 94 | borderRadius: 20, | 94 | borderRadius: 20, |
| 95 | color: PdfColors.white, | 95 | color: PdfColors.white, |
| 96 | - border: BoxBorder( | 96 | + border: const BoxBorder( |
| 97 | color: PdfColors.blue, | 97 | color: PdfColors.blue, |
| 98 | top: true, | 98 | top: true, |
| 99 | bottom: true, | 99 | bottom: true, |
No preview for this file type
-
Please register or login to post a comment