Showing
1 changed file
with
43 additions
and
1 deletions
| @@ -88,6 +88,42 @@ class _MultiPageInstance { | @@ -88,6 +88,42 @@ class _MultiPageInstance { | ||
| 88 | final List<_MultiPageWidget> widgets = <_MultiPageWidget>[]; | 88 | final List<_MultiPageWidget> widgets = <_MultiPageWidget>[]; |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | +/// Create a mult-page section, with automatic overflow from one page to another | ||
| 92 | +/// | ||
| 93 | +/// ```dart | ||
| 94 | +/// final pdf = Document(); | ||
| 95 | +/// pdf.addPage(MultiPage(build: (context) { | ||
| 96 | +/// return [ | ||
| 97 | +/// Text('Hello'), | ||
| 98 | +/// Text('World'), | ||
| 99 | +/// ]; | ||
| 100 | +/// })); | ||
| 101 | +/// | ||
| 102 | +/// An inner widget tree cannot be bigger than a page: A [Widget] cannot be drawn | ||
| 103 | +/// partially on one page and the remaining on another page: It's insecable. | ||
| 104 | +/// | ||
| 105 | +/// A small set of [Widget] can automatically span over multiple pages, and can | ||
| 106 | +/// be used as a direct child of the build method: [Flex], [Partition], [Table], [Wrap], | ||
| 107 | +/// [GridView], and [Column]. | ||
| 108 | +/// | ||
| 109 | +/// ```dart | ||
| 110 | +/// final pdf = Document(); | ||
| 111 | +/// pdf.addPage(MultiPage(build: (context) { | ||
| 112 | +/// return [ | ||
| 113 | +/// Text('Hello'), | ||
| 114 | +/// Wrap( | ||
| 115 | +/// children: [ | ||
| 116 | +/// Text('One'), | ||
| 117 | +/// Text('Two'), | ||
| 118 | +/// Text('Three'), | ||
| 119 | +/// ] | ||
| 120 | +/// ), | ||
| 121 | +/// ]; | ||
| 122 | +/// })); | ||
| 123 | +/// ``` | ||
| 124 | +/// | ||
| 125 | +/// The [Wrap] [Widget] here is able to rearrange its children to span them across | ||
| 126 | +/// multiple pages. But a child of [Wrap] must fit in a page, or an error will raise. | ||
| 91 | class MultiPage extends Page { | 127 | class MultiPage extends Page { |
| 92 | MultiPage({ | 128 | MultiPage({ |
| 93 | PageTheme? pageTheme, | 129 | PageTheme? pageTheme, |
| @@ -116,16 +152,22 @@ class MultiPage extends Page { | @@ -116,16 +152,22 @@ class MultiPage extends Page { | ||
| 116 | 152 | ||
| 117 | final BuildListCallback _buildList; | 153 | final BuildListCallback _buildList; |
| 118 | 154 | ||
| 155 | + /// How the children should be placed along the cross axis. | ||
| 119 | final CrossAxisAlignment crossAxisAlignment; | 156 | final CrossAxisAlignment crossAxisAlignment; |
| 120 | 157 | ||
| 158 | + /// A builder for the page header. | ||
| 121 | final BuildCallback? header; | 159 | final BuildCallback? header; |
| 122 | 160 | ||
| 161 | + /// A builder for the page footer. | ||
| 123 | final BuildCallback? footer; | 162 | final BuildCallback? footer; |
| 124 | 163 | ||
| 164 | + /// How the children should be placed along the main axis. | ||
| 125 | final MainAxisAlignment mainAxisAlignment; | 165 | final MainAxisAlignment mainAxisAlignment; |
| 126 | 166 | ||
| 127 | final List<_MultiPageInstance> _pages = <_MultiPageInstance>[]; | 167 | final List<_MultiPageInstance> _pages = <_MultiPageInstance>[]; |
| 128 | 168 | ||
| 169 | + /// The maximum number of pages allowed before raising an error. | ||
| 170 | + /// This is not checked with a Release build. | ||
| 129 | final int maxPages; | 171 | final int maxPages; |
| 130 | 172 | ||
| 131 | void _paintChild( | 173 | void _paintChild( |
| @@ -196,7 +238,7 @@ class MultiPage extends Page { | @@ -196,7 +238,7 @@ class MultiPage extends Page { | ||
| 196 | // Detect too big widgets | 238 | // Detect too big widgets |
| 197 | if (sameCount++ > maxPages) { | 239 | if (sameCount++ > maxPages) { |
| 198 | throw Exception( | 240 | throw Exception( |
| 199 | - 'This widget created more than $maxPages pages. This may be an issue in the widget or the document.'); | 241 | + 'This widget created more than $maxPages pages. This may be an issue in the widget or the document. See https://pub.dev/documentation/pdf/latest/widgets/MultiPage-class.html'); |
| 200 | } | 242 | } |
| 201 | return true; | 243 | return true; |
| 202 | }()); | 244 | }()); |
-
Please register or login to post a comment