1

this is my code

build: (pw.Context context) => <pw.Widget>[
    pw.Header(
        level: 0,
        child:pw.Row(
            mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
            children: <pw.Widget>[
              pw.Text(userDetailsInfo[0].name,  style: pw.TextStyle(font: myFont,fontSize: 20
              ),textScaleFactor: 2),
              pw.PdfLogo( )
            ])),
    pw.SizedBox(height: 15),
    pw.Row(
       mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
       children: [
         pw.Text('Total : ', style: pw.TextStyle(fontSize: 20)),
         pw.Text('$total dh', style: pw.TextStyle(fontSize: 20,color: PdfColors.green)),
       ]
    ),
    pw.SizedBox(height: 15),
    pw.ListView.builder(itemBuilder: (context,index)
        {
          return pw.Column(
            children: [
          pw.Row(
          mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
              children: [
                pw.Text((index + 1).toString()),
                pw.Text(userDetailsInfo[index].product, style: pw.TextStyle(font: myFont,fontSize: 15)),
                pw.Text("${userDetailsInfo[index].price.toString()} dh",style: pw.TextStyle(fontSize: 15,
                color: userDetailsInfo[index].condition == 'give' ? PdfColors.red: PdfColors.green)),

                pw.Text( DateFormat('dd/MM/yyyy').format(userDetailsInfo[index].creationDate),style: pw.TextStyle(fontSize: 15,)),
              ]
          ),
          pw.SizedBox(height: 10),
              pw.Divider( )
            ]
          );
        },
        itemCount: userDetailsInfo.length)

*when my list userDetailsInfo exceed a specific length flutter throw an exception: This widget created more than 20 pages. This may be an issue in the widget or the document. *

My question is how to split my listview.builder or there is another solution for this issue

  • Try looking here: https://stackoverflow.com/questions/61679628/flutter-pdf-error-this-widget-created-more-than-20-pages-this-may-be-an-i – il_boga Feb 05 '21 at 10:59

0 Answers0