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-09-10 20:25:07 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d81364513b08f561b906d3b97d5a4a93b6e0933a
d8136451
1 parent
9476aaeb
Fix Table.fromTextArray vertical alignment
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
4 deletions
pdf/CHANGELOG.md
pdf/lib/widgets/table.dart
pdf/pubspec.yaml
pdf/test/widget_table_test.dart
test/golden/widgets-table.pdf
pdf/CHANGELOG.md
View file @
d813645
...
...
@@ -2,6 +2,10 @@
## 1.11.1
-
Fix Table.fromTextArray vertical alignment
## 1.11.1
-
Fix Table.fromTextArray alignments with multi-lines text
-
Fix parameter type typo in Table.fromTextArray
[
Uli Prantz
]
...
...
pdf/lib/widgets/table.dart
View file @
d813645
...
...
@@ -39,7 +39,7 @@ class TableRow {
final
TableCellVerticalAlignment
verticalAlignment
;
}
enum
TableCellVerticalAlignment
{
bottom
,
middle
,
top
}
enum
TableCellVerticalAlignment
{
bottom
,
middle
,
top
,
full
}
enum
TableWidth
{
min
,
max
}
...
...
@@ -345,6 +345,7 @@ class Table extends Widget implements SpanningWidget {
children:
rows
,
columnWidths:
columnWidths
,
defaultColumnWidth:
defaultColumnWidth
,
defaultVerticalAlignment:
TableCellVerticalAlignment
.
full
,
);
}
...
...
@@ -471,6 +472,25 @@ class Table extends Widget implements SpanningWidget {
n
++;
}
final
TableCellVerticalAlignment
align
=
row
.
verticalAlignment
??
defaultVerticalAlignment
;
if
(
align
==
TableCellVerticalAlignment
.
full
)
{
// Compute the layout again to give the full height to all cells
n
=
0
;
x
=
0
;
for
(
Widget
child
in
row
.
children
)
{
final
BoxConstraints
childConstraints
=
BoxConstraints
.
tightFor
(
width:
_widths
[
n
],
height:
lineHeight
);
child
.
layout
(
context
,
childConstraints
);
assert
(
child
.
box
!=
null
);
child
.
box
=
PdfRect
(
x
,
totalHeight
,
child
.
box
.
width
,
child
.
box
.
height
);
x
+=
_widths
[
n
];
n
++;
}
}
if
(
totalHeight
+
lineHeight
>
constraints
.
maxHeight
)
{
index
--;
break
;
...
...
@@ -504,6 +524,7 @@ class Table extends Widget implements SpanningWidget {
(
_heights
[
heightIndex
]
+
child
.
box
.
height
)
/
2
;
break
;
case
TableCellVerticalAlignment
.
top
:
case
TableCellVerticalAlignment
.
full
:
childY
=
totalHeight
-
child
.
box
.
y
-
child
.
box
.
height
;
break
;
}
...
...
pdf/pubspec.yaml
View file @
d813645
...
...
@@ -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.11.
1
version
:
1.11.
2
environment
:
sdk
:
"
>=2.3.0
<3.0.0"
...
...
pdf/test/widget_table_test.dart
View file @
d813645
...
...
@@ -253,6 +253,21 @@ void main() {
));
});
test
(
'Table fromTextArray with alignment'
,
()
{
pdf
.
addPage
(
Page
(
build:
(
Context
context
)
=>
Table
.
fromTextArray
(
cellAlignment:
Alignment
.
center
,
data:
<
List
<
String
>>[
<
String
>[
'line 1'
,
'Text
\n\n\n
text'
],
<
String
>[
'line 2'
,
'Text
\n\n\n
text'
],
<
String
>[
'line 3'
,
'Text
\n\n\n
text'
],
],
),
),
);
});
tearDownAll
(()
{
final
File
file
=
File
(
'widgets-table.pdf'
);
file
.
writeAsBytesSync
(
pdf
.
save
());
...
...
test/golden/widgets-table.pdf
View file @
d813645
No preview for this file type
Please
register
or
login
to post a comment