dart_pdf
dart_pdf copied to clipboard
Footer placement
I am having a problem with my footer with the pdf package in flutter. What I want to achieve is I want to place the footer at the top of the last page if the footerContent() is the only widget in the last page. And if not, for example, the table content expands until the 2nd page but not covering the whole page, the footerContent() will be at the bottom of that last page which I succeed at doing by enclosing it to Expanded and then Container and set the alignment to bottomCenter.
However I cannot think of a way to determine if the footerContent() is the only widget in the page. I tried the doc.document.pdfPageList.pages.last.contents.length, but the value is always 1 and I checked the 1st page which has multiple content and it is still 1 value. I don't know how to know and how to do the results that I want.
This is the doc.addPage part of the code:
final doc = pw.Document();
doc.addPage( pw.MultiPage( build: (context) => [ _buildHeader(context, mode), _contentHeader(context), _contentTable(context), pw.SizedBox(height: CustomSpacing.medium), pw.Expanded( child: pw.Container( alignment: pw.Alignment.bottomCenter, child: _footerContent(context), )), ], ), );