MultiPage class

Create a multi-page section, with automatic overflow from one page to another

final pdf = Document();
pdf.addPage(MultiPage(build: (context) {
  return [
    Text('Hello'),
    Text('World'),
  ];
}));

An inner widget tree cannot be bigger than a page: A Widget cannot be drawn partially on one page and the remaining on another page: It's unbreakable.

A small set of Widget can automatically span over multiple pages, and can be used as a direct child of the build method: Flex, Partition, Table, Wrap, GridView, and Column.

final pdf = Document();
pdf.addPage(MultiPage(build: (context) {
  return [
    Text('Hello'),
    Wrap(
      children: [
        Text('One'),
        Text('Two'),
        Text('Three'),
      ]
    ),
  ];
}));

The Wrap Widget here is able to rearrange its children to span them across multiple pages. But a child of Wrap must fit in a page, or an error will raise.

Use Inseparable to control page breaking. By default (canSpan: false), widgets stay on one page. Set canSpan: true to allow spanning:

final pdf = Document();
pdf.addPage(MultiPage(build: (context) {
  return [
    Text('Header'),
    Inseparable(
      canSpan: true,  // Allows spanning if content is too large
      child: Wrap(
        children: [
          Text('This wrap can span'),
          Text('across multiple pages'),
        ]
      )
    ),
  ];
}));
Inheritance

Constructors

MultiPage({PageTheme? pageTheme, PdfPageFormat? pageFormat, required BuildListCallback build, MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start, CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.start, BuildCallback? header, BuildCallback? footer, ThemeData? theme, int maxPages = 20, PageOrientation? orientation, EdgeInsetsGeometry? margin, TextDirection? textDirection})

Properties

crossAxisAlignment → CrossAxisAlignment
How the children should be placed along the cross axis.
final
A builder for the page footer.
final
hashCode → int
The hash code for this object.
no setterinherited
A builder for the page header.
final
mainAxisAlignment → MainAxisAlignment
How the children should be placed along the main axis.
final
margin → EdgeInsetsGeometry?
no setterinherited
maxPages → int
The maximum number of pages allowed before raising an error. This is not checked with a Release build.
final
mustRotate → bool
no setterinherited
orientation → PageOrientation
no setterinherited
pageFormat → PdfPageFormat
no setterinherited
pageTheme → PageTheme
finalinherited
resolvedMargin → EdgeInsets?
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
theme → ThemeData?
no setterinherited

Methods

debugPaint(Context context) → void
inherited
generate(Document document, {bool insert = true, int? index}) → void
override
layout(Widget child, Context context, BoxConstraints constraints, {bool parentUsesSize = false}) → PdfPoint
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
paint(Widget child, Context context) → void
inherited
postProcess(Document document) → void
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited