Showing
8 changed files
with
21 additions
and
0 deletions
@@ -50,6 +50,7 @@ class LimitedBox extends SingleChildWidget { | @@ -50,6 +50,7 @@ class LimitedBox extends SingleChildWidget { | ||
50 | if (child != null) { | 50 | if (child != null) { |
51 | child.layout(context, _limitConstraints(constraints), | 51 | child.layout(context, _limitConstraints(constraints), |
52 | parentUsesSize: true); | 52 | parentUsesSize: true); |
53 | + assert(child.box != null); | ||
53 | size = constraints.constrain(child.box.size); | 54 | size = constraints.constrain(child.box.size); |
54 | } else { | 55 | } else { |
55 | size = _limitConstraints(constraints).constrain(PdfPoint.zero); | 56 | size = _limitConstraints(constraints).constrain(PdfPoint.zero); |
@@ -73,6 +74,7 @@ class Padding extends SingleChildWidget { | @@ -73,6 +74,7 @@ class Padding extends SingleChildWidget { | ||
73 | if (child != null) { | 74 | if (child != null) { |
74 | final BoxConstraints childConstraints = constraints.deflate(padding); | 75 | final BoxConstraints childConstraints = constraints.deflate(padding); |
75 | child.layout(context, childConstraints, parentUsesSize: parentUsesSize); | 76 | child.layout(context, childConstraints, parentUsesSize: parentUsesSize); |
77 | + assert(child.box != null); | ||
76 | box = constraints.constrainRect( | 78 | box = constraints.constrainRect( |
77 | width: child.box.width + padding.horizontal, | 79 | width: child.box.width + padding.horizontal, |
78 | height: child.box.height + padding.vertical); | 80 | height: child.box.height + padding.vertical); |
@@ -239,6 +241,7 @@ class Align extends SingleChildWidget { | @@ -239,6 +241,7 @@ class Align extends SingleChildWidget { | ||
239 | 241 | ||
240 | if (child != null) { | 242 | if (child != null) { |
241 | child.layout(context, constraints.loosen(), parentUsesSize: true); | 243 | child.layout(context, constraints.loosen(), parentUsesSize: true); |
244 | + assert(child.box != null); | ||
242 | 245 | ||
243 | box = constraints.constrainRect( | 246 | box = constraints.constrainRect( |
244 | width: shrinkWrapWidth | 247 | width: shrinkWrapWidth |
@@ -272,6 +275,7 @@ class ConstrainedBox extends SingleChildWidget { | @@ -272,6 +275,7 @@ class ConstrainedBox extends SingleChildWidget { | ||
272 | if (child != null) { | 275 | if (child != null) { |
273 | child.layout(context, this.constraints.enforce(constraints), | 276 | child.layout(context, this.constraints.enforce(constraints), |
274 | parentUsesSize: true); | 277 | parentUsesSize: true); |
278 | + assert(child.box != null); | ||
275 | box = child.box; | 279 | box = child.box; |
276 | } else { | 280 | } else { |
277 | box = PdfRect.fromPoints(PdfPoint.zero, | 281 | box = PdfRect.fromPoints(PdfPoint.zero, |
@@ -308,6 +312,7 @@ class FittedBox extends SingleChildWidget { | @@ -308,6 +312,7 @@ class FittedBox extends SingleChildWidget { | ||
308 | PdfPoint size; | 312 | PdfPoint size; |
309 | if (child != null) { | 313 | if (child != null) { |
310 | child.layout(context, const BoxConstraints(), parentUsesSize: true); | 314 | child.layout(context, const BoxConstraints(), parentUsesSize: true); |
315 | + assert(child.box != null); | ||
311 | size = constraints | 316 | size = constraints |
312 | .constrainSizeAndAttemptToPreserveAspectRatio(child.box.size); | 317 | .constrainSizeAndAttemptToPreserveAspectRatio(child.box.size); |
313 | } else { | 318 | } else { |
@@ -397,6 +402,7 @@ class AspectRatio extends SingleChildWidget { | @@ -397,6 +402,7 @@ class AspectRatio extends SingleChildWidget { | ||
397 | if (child != null) | 402 | if (child != null) |
398 | child.layout(context, | 403 | child.layout(context, |
399 | BoxConstraints.tightFor(width: box.width, height: box.height)); | 404 | BoxConstraints.tightFor(width: box.width, height: box.height)); |
405 | + assert(child.box != null); | ||
400 | } | 406 | } |
401 | } | 407 | } |
402 | 408 | ||
@@ -420,6 +426,7 @@ class CustomPaint extends SingleChildWidget { | @@ -420,6 +426,7 @@ class CustomPaint extends SingleChildWidget { | ||
420 | if (child != null) { | 426 | if (child != null) { |
421 | child.layout(context, constraints.tighten(width: size.x, height: size.y), | 427 | child.layout(context, constraints.tighten(width: size.x, height: size.y), |
422 | parentUsesSize: parentUsesSize); | 428 | parentUsesSize: parentUsesSize); |
429 | + assert(child.box != null); | ||
423 | box = child.box; | 430 | box = child.box; |
424 | } else { | 431 | } else { |
425 | box = PdfRect.fromPoints(PdfPoint.zero, constraints.constrain(size)); | 432 | box = PdfRect.fromPoints(PdfPoint.zero, constraints.constrain(size)); |
@@ -152,6 +152,7 @@ class Page { | @@ -152,6 +152,7 @@ class Page { | ||
152 | if (child != null) { | 152 | if (child != null) { |
153 | final EdgeInsets _margin = margin; | 153 | final EdgeInsets _margin = margin; |
154 | child.layout(context, constraints, parentUsesSize: parentUsesSize); | 154 | child.layout(context, constraints, parentUsesSize: parentUsesSize); |
155 | + assert(child.box != null); | ||
155 | child.box = PdfRect( | 156 | child.box = PdfRect( |
156 | _margin.left, | 157 | _margin.left, |
157 | pageFormat.height - child.box.height - _margin.top, | 158 | pageFormat.height - child.box.height - _margin.top, |
@@ -260,6 +260,7 @@ class Flex extends MultiChildWidget { | @@ -260,6 +260,7 @@ class Flex extends MultiChildWidget { | ||
260 | } | 260 | } |
261 | } | 261 | } |
262 | child.layout(context, innerConstraints, parentUsesSize: true); | 262 | child.layout(context, innerConstraints, parentUsesSize: true); |
263 | + assert(child.box != null); | ||
263 | allocatedSize += _getMainSize(child); | 264 | allocatedSize += _getMainSize(child); |
264 | crossSize = math.max(crossSize, _getCrossSize(child)); | 265 | crossSize = math.max(crossSize, _getCrossSize(child)); |
265 | } | 266 | } |
@@ -329,6 +330,7 @@ class Flex extends MultiChildWidget { | @@ -329,6 +330,7 @@ class Flex extends MultiChildWidget { | ||
329 | } | 330 | } |
330 | } | 331 | } |
331 | child.layout(context, innerConstraints, parentUsesSize: true); | 332 | child.layout(context, innerConstraints, parentUsesSize: true); |
333 | + assert(child.box != null); | ||
332 | final double childSize = _getMainSize(child); | 334 | final double childSize = _getMainSize(child); |
333 | assert(childSize <= maxChildExtent); | 335 | assert(childSize <= maxChildExtent); |
334 | allocatedSize += childSize; | 336 | allocatedSize += childSize; |
@@ -138,6 +138,7 @@ class GridView extends MultiChildWidget implements SpanningWidget { | @@ -138,6 +138,7 @@ class GridView extends MultiChildWidget implements SpanningWidget { | ||
138 | math.min(children.length, | 138 | math.min(children.length, |
139 | _context.firstChild + crossAxisCount * _mainAxisCount))) { | 139 | _context.firstChild + crossAxisCount * _mainAxisCount))) { |
140 | child.layout(context, innerConstraints); | 140 | child.layout(context, innerConstraints); |
141 | + assert(child.box != null); | ||
141 | 142 | ||
142 | switch (direction) { | 143 | switch (direction) { |
143 | case Axis.vertical: | 144 | case Axis.vertical: |
@@ -143,6 +143,7 @@ class MultiPage extends Page { | @@ -143,6 +143,7 @@ class MultiPage extends Page { | ||
143 | final Widget headerWidget = header(context); | 143 | final Widget headerWidget = header(context); |
144 | if (headerWidget != null) { | 144 | if (headerWidget != null) { |
145 | headerWidget.layout(context, constraints, parentUsesSize: false); | 145 | headerWidget.layout(context, constraints, parentUsesSize: false); |
146 | + assert(headerWidget.box != null); | ||
146 | _paintChild(context, headerWidget, _margin.left, | 147 | _paintChild(context, headerWidget, _margin.left, |
147 | offsetStart - headerWidget.box.height, pageFormat.height); | 148 | offsetStart - headerWidget.box.height, pageFormat.height); |
148 | offsetStart -= headerWidget.box.height; | 149 | offsetStart -= headerWidget.box.height; |
@@ -153,6 +154,7 @@ class MultiPage extends Page { | @@ -153,6 +154,7 @@ class MultiPage extends Page { | ||
153 | final Widget footerWidget = footer(context); | 154 | final Widget footerWidget = footer(context); |
154 | if (footerWidget != null) { | 155 | if (footerWidget != null) { |
155 | footerWidget.layout(context, constraints, parentUsesSize: false); | 156 | footerWidget.layout(context, constraints, parentUsesSize: false); |
157 | + assert(footerWidget.box != null); | ||
156 | _paintChild(context, footerWidget, _margin.left, _margin.bottom, | 158 | _paintChild(context, footerWidget, _margin.left, _margin.bottom, |
157 | pageFormat.height); | 159 | pageFormat.height); |
158 | offsetEnd += footerWidget.box.height; | 160 | offsetEnd += footerWidget.box.height; |
@@ -167,6 +169,7 @@ class MultiPage extends Page { | @@ -167,6 +169,7 @@ class MultiPage extends Page { | ||
167 | } | 169 | } |
168 | 170 | ||
169 | child.layout(context, constraints, parentUsesSize: false); | 171 | child.layout(context, constraints, parentUsesSize: false); |
172 | + assert(child.box != null); | ||
170 | 173 | ||
171 | // What to do if the widget is too big for the page? | 174 | // What to do if the widget is too big for the page? |
172 | if (offsetStart - child.box.height < offsetEnd) { | 175 | if (offsetStart - child.box.height < offsetEnd) { |
@@ -191,6 +194,7 @@ class MultiPage extends Page { | @@ -191,6 +194,7 @@ class MultiPage extends Page { | ||
191 | child.layout( | 194 | child.layout( |
192 | context, constraints.copyWith(maxHeight: offsetStart - offsetEnd), | 195 | context, constraints.copyWith(maxHeight: offsetStart - offsetEnd), |
193 | parentUsesSize: false); | 196 | parentUsesSize: false); |
197 | + assert(child.box != null); | ||
194 | _paintChild(context, child, _margin.left, | 198 | _paintChild(context, child, _margin.left, |
195 | offsetStart - child.box.height, pageFormat.height); | 199 | offsetStart - child.box.height, pageFormat.height); |
196 | 200 |
@@ -100,6 +100,7 @@ class Stack extends MultiChildWidget { | @@ -100,6 +100,7 @@ class Stack extends MultiChildWidget { | ||
100 | hasNonPositionedChildren = true; | 100 | hasNonPositionedChildren = true; |
101 | 101 | ||
102 | child.layout(context, nonPositionedConstraints, parentUsesSize: true); | 102 | child.layout(context, nonPositionedConstraints, parentUsesSize: true); |
103 | + assert(child.box != null); | ||
103 | 104 | ||
104 | final PdfRect childSize = child.box; | 105 | final PdfRect childSize = child.box; |
105 | width = math.max(width, childSize.width); | 106 | width = math.max(width, childSize.width); |
@@ -137,6 +138,7 @@ class Stack extends MultiChildWidget { | @@ -137,6 +138,7 @@ class Stack extends MultiChildWidget { | ||
137 | childConstraints.tighten(height: positioned.height); | 138 | childConstraints.tighten(height: positioned.height); |
138 | 139 | ||
139 | positioned.layout(context, childConstraints, parentUsesSize: true); | 140 | positioned.layout(context, childConstraints, parentUsesSize: true); |
141 | + assert(positioned.box != null); | ||
140 | 142 | ||
141 | double x; | 143 | double x; |
142 | if (positioned.left != null) { | 144 | if (positioned.left != null) { |
@@ -163,6 +163,7 @@ class Table extends Widget implements SpanningWidget { | @@ -163,6 +163,7 @@ class Table extends Widget implements SpanningWidget { | ||
163 | int n = 0; | 163 | int n = 0; |
164 | for (Widget child in row.children) { | 164 | for (Widget child in row.children) { |
165 | child.layout(context, const BoxConstraints()); | 165 | child.layout(context, const BoxConstraints()); |
166 | + assert(child.box != null); | ||
166 | final double calculatedWidth = | 167 | final double calculatedWidth = |
167 | child.box.width == double.infinity ? 0.0 : child.box.width; | 168 | child.box.width == double.infinity ? 0.0 : child.box.width; |
168 | final double childFlex = child is Expanded | 169 | final double childFlex = child is Expanded |
@@ -227,6 +228,7 @@ class Table extends Widget implements SpanningWidget { | @@ -227,6 +228,7 @@ class Table extends Widget implements SpanningWidget { | ||
227 | final BoxConstraints childConstraints = | 228 | final BoxConstraints childConstraints = |
228 | BoxConstraints.tightFor(width: _widths[n]); | 229 | BoxConstraints.tightFor(width: _widths[n]); |
229 | child.layout(context, childConstraints); | 230 | child.layout(context, childConstraints); |
231 | + assert(child.box != null); | ||
230 | child.box = PdfRect(x, totalHeight, child.box.width, child.box.height); | 232 | child.box = PdfRect(x, totalHeight, child.box.width, child.box.height); |
231 | x += _widths[n]; | 233 | x += _widths[n]; |
232 | lineHeight = math.max(lineHeight, child.box.height); | 234 | lineHeight = math.max(lineHeight, child.box.height); |
@@ -104,6 +104,7 @@ abstract class StatelessWidget extends Widget { | @@ -104,6 +104,7 @@ abstract class StatelessWidget extends Widget { | ||
104 | 104 | ||
105 | if (_child != null) { | 105 | if (_child != null) { |
106 | _child.layout(context, constraints, parentUsesSize: parentUsesSize); | 106 | _child.layout(context, constraints, parentUsesSize: parentUsesSize); |
107 | + assert(_child.box != null); | ||
107 | box = _child.box; | 108 | box = _child.box; |
108 | } else { | 109 | } else { |
109 | box = PdfRect.fromPoints(PdfPoint.zero, constraints.smallest); | 110 | box = PdfRect.fromPoints(PdfPoint.zero, constraints.smallest); |
@@ -139,6 +140,7 @@ abstract class SingleChildWidget extends Widget { | @@ -139,6 +140,7 @@ abstract class SingleChildWidget extends Widget { | ||
139 | {bool parentUsesSize = false}) { | 140 | {bool parentUsesSize = false}) { |
140 | if (child != null) { | 141 | if (child != null) { |
141 | child.layout(context, constraints, parentUsesSize: parentUsesSize); | 142 | child.layout(context, constraints, parentUsesSize: parentUsesSize); |
143 | + assert(child.box != null); | ||
142 | box = child.box; | 144 | box = child.box; |
143 | } else { | 145 | } else { |
144 | box = PdfRect.fromPoints(PdfPoint.zero, constraints.smallest); | 146 | box = PdfRect.fromPoints(PdfPoint.zero, constraints.smallest); |
-
Please register or login to post a comment