dart_pdf
dart_pdf copied to clipboard
fix RTL Table View
to fix RTL Table View that show content table from left to right instead of right to left i add an option to show RTL content in table as proper RTL direction just by adding .showRTL() in headers & data .
example code:
final table = pw.Table.fromTextArray(
headers: tableHeaders.showRTL(),
data: tableData.showRTL(),
...
before add showRTL:
after add showRTL:
Codecov Report
Merging #1147 (78bb055) into master (016cba4) will decrease coverage by
0.21%
. The diff coverage is0.00%
.
@@ Coverage Diff @@
## master #1147 +/- ##
==========================================
- Coverage 38.35% 38.13% -0.22%
==========================================
Files 131 131
Lines 19550 19523 -27
==========================================
- Hits 7499 7446 -53
- Misses 12051 12077 +26
Impacted Files | Coverage Δ | |
---|---|---|
pdf/lib/src/widgets/table.dart | 93.14% <0.00%> (-2.74%) |
:arrow_down: |
pdf/lib/src/pdf/obj/border.dart | 0.00% <0.00%> (-10.00%) |
:arrow_down: |
pdf/lib/src/pdf/obj/signature.dart | 0.00% <0.00%> (-4.55%) |
:arrow_down: |
pdf/lib/src/pdf/obj/page_label.dart | 0.00% <0.00%> (-1.67%) |
:arrow_down: |
pdf/lib/src/widgets/chart/point_chart.dart | 32.69% <0.00%> (-1.27%) |
:arrow_down: |
pdf/lib/src/pdf/document.dart | 73.91% <0.00%> (-1.09%) |
:arrow_down: |
pdf/lib/src/pdf/obj/outline.dart | 74.07% <0.00%> (-0.93%) |
:arrow_down: |
pdf/lib/src/pdf/obj/page.dart | 72.22% <0.00%> (-0.76%) |
:arrow_down: |
pdf/lib/src/widgets/flex.dart | 71.76% <0.00%> (-0.65%) |
:arrow_down: |
pdf/lib/src/widgets/decoration.dart | 75.79% <0.00%> (-0.61%) |
:arrow_down: |
... and 26 more |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
It's not the right way to do it. Flutter automatically reverse the columns when there is a Directionality(textDirection: TextDirection.rtl) ancester Widget.
@DavBfr so why it shows the wrong direction even if we use textDirection as RTL? can we fix it and integrated with (textDirection == TextDirection.rtl) to do my method automatically!
like:
if (textDirection == TextDirection.rtl) {
headers= headers.showRTL();
data= data.showRTL();
} else {
headers= headers;
data= data;
}
The table layout must take the direction into account. in this function: https://github.com/DavBfr/dart_pdf/blob/master/pdf/lib/src/widgets/table.dart#L432