Marcin Jeleński
Committed by GitHub

Throw multi pages error explicitly (#1455)

1 # Changelog 1 # Changelog
2 2
  3 +## 3.10.6
  4 +
  5 +- Throw multi page error explicitly.
  6 +
3 ## 3.10.5 7 ## 3.10.5
4 8
5 - Improve TTF writer with multi-compound characters 9 - Improve TTF writer with multi-compound characters
@@ -246,14 +246,11 @@ class MultiPage extends Page { @@ -246,14 +246,11 @@ class MultiPage extends Page {
246 while (_index < children.length) { 246 while (_index < children.length) {
247 final child = children[_index]; 247 final child = children[_index];
248 248
249 - assert(() {  
250 - // Detect too big widgets  
251 - if (sameCount++ > maxPages) {  
252 - throw Exception(  
253 - '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');  
254 - }  
255 - return true;  
256 - }()); 249 + // Detect too big widgets
  250 + if (sameCount++ > maxPages) {
  251 + throw TooManyPagesException(
  252 + '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');
  253 + }
257 254
258 // Create a new page if we don't already have one 255 // Create a new page if we don't already have one
259 if (context == null || child is NewPage) { 256 if (context == null || child is NewPage) {
@@ -579,3 +576,10 @@ class MultiPage extends Page { @@ -579,3 +576,10 @@ class MultiPage extends Page {
579 } 576 }
580 } 577 }
581 } 578 }
  579 +
  580 +/// Exception thrown when generator populates more pages than [maxPages].
  581 +class TooManyPagesException implements Exception {
  582 + TooManyPagesException(this.message);
  583 +
  584 + final String message;
  585 +}
@@ -6,7 +6,7 @@ issue_tracker: https://github.com/DavBfr/dart_pdf/issues @@ -6,7 +6,7 @@ issue_tracker: https://github.com/DavBfr/dart_pdf/issues
6 screenshots: 6 screenshots:
7 - description: 'Example of a generated document' 7 - description: 'Example of a generated document'
8 path: example.jpg 8 path: example.jpg
9 -version: 3.10.5 9 +version: 3.10.6
10 10
11 environment: 11 environment:
12 sdk: ">=2.18.0 <4.0.0" 12 sdk: ">=2.18.0 <4.0.0"