I want to create a pdf document with the package 'pdf'. I show long list in table on the pdf. I want to create a dynamic table in the pdf document.
I cannot dynamically and programatically create all row in the table. I cannot show long list in table.........
static Future<File> generateTable(
List<ReportPerson>? report_list,
String name,
String phone,
String date1,
String date2,
String time1,
String time2,
BuildContext context) async {
BlocProvider.of<Show_ProgrssIndicator_Bloc>(context)
.add(Toggle_progressview());
var datafont = await rootBundle.load("fonts/IRANSansWeb(FaNum).ttf");
final ttf = pw.Font.ttf(datafont);
final headers = ['واحد', 'تعداد', 'نوع بار', 'ردیف'];
final data = report_list!
.map((users) =>
[users.type, users.productCount, users.productName, users.radif])
.toList();
//print (data);
final pdf = pw.Document();
pdf.addPage(pw.MultiPage(
build: (context) {
return <pw.Widget>[
pw.Column(children: [
pw.Row(children: [
pw.Text(name),
pw.Text("name: "),
]),
pw.SizedBox(height: 10),
pw.Table.fromTextArray(
headers: headers,
data: data,
cellAlignment: pw.Alignment.center,
columnWidths: {
0: const pw.FlexColumnWidth(15),
1: const pw.FlexColumnWidth(9),
2: const pw.FlexColumnWidth(13),
3: const pw.FlexColumnWidth(10),
4: const pw.FlexColumnWidth(13),
5: const pw.FlexColumnWidth(15),
6: const pw.FlexColumnWidth(13),
}),
]),
];
},
// pageFormat: PdfPageFormat.a6,
textDirection: pw.TextDirection.rtl,
theme: pw.ThemeData.withFont(
base: ttf,
)));
BlocProvider.of<Show_ProgrssIndicator_Bloc>(context)
.add(Toggle_progressview());
return saveDocument(name: 'ReportFile.pdf', pdf: pdf);