Flutter Printing Package: Create pdf table with loop
4,638
I ran into the same issue. This seemed to work for me.
pdf.addPage(
MultiPage(
build: (context) => [
Table.fromTextArray(context: context, data: <List<String>>[
<String>['Msg ID', 'DateTime', 'Type', 'Body'],
...msgList.map(
(msg) => [msg.counter, msg.dateTimeStamp, msg.type, msg.body])
]),
],
),
);
where my msgList
object was a custom List, ie: List<SingleMessage>
Author by
Markus Bach
Updated on December 14, 2022Comments
-
Markus Bach over 1 year
I want to create a pdf document with the package 'pdf'. The example on the dart - page is working fine: https://pub.dev/packages/pdf#-example-tab-
You can see that the table is static. I want to create a dynamic table in the pdf document.
The columns will be constant, but the rows have to be dynamic.
I have tried to insert a for() - loop.
The syntax is not correct.
pdfWidget.Table.fromTextArray(context: context, data: <List<String>> [ <String>['Date', 'PDF Version', 'Acrobat Version'], //..... //more Strings here..... ]),
-
Markus Bach over 4 yearsI solved the issue. Does anyone want to know the solution?
-
-
kriti sharma about 4 yearsIt is showing me error I am not able to add recind to salidas as salidas showing error "the arugment type Map<String,Dynamic> can't be assigned to the parameter type List<String>
-
Mario Cristerna about 4 years@kritisharma: I am sorry, I made a mistake. I just edit the code, this has to work