Showing
6 changed files
with
49 additions
and
41 deletions
@@ -57,6 +57,12 @@ class LimitedBox extends SingleChildWidget { | @@ -57,6 +57,12 @@ class LimitedBox extends SingleChildWidget { | ||
57 | } | 57 | } |
58 | box = PdfRect.fromPoints(PdfPoint.zero, size); | 58 | box = PdfRect.fromPoints(PdfPoint.zero, size); |
59 | } | 59 | } |
60 | + | ||
61 | + @override | ||
62 | + void paint(Context context) { | ||
63 | + super.paint(context); | ||
64 | + paintChild(context); | ||
65 | + } | ||
60 | } | 66 | } |
61 | 67 | ||
62 | class Padding extends SingleChildWidget { | 68 | class Padding extends SingleChildWidget { |
@@ -101,12 +107,7 @@ class Padding extends SingleChildWidget { | @@ -101,12 +107,7 @@ class Padding extends SingleChildWidget { | ||
101 | 107 | ||
102 | @override | 108 | @override |
103 | void paint(Context context) { | 109 | void paint(Context context) { |
104 | - assert(() { | ||
105 | - if (Document.debug) { | ||
106 | - debugPaint(context); | ||
107 | - } | ||
108 | - return true; | ||
109 | - }()); | 110 | + super.paint(context); |
110 | 111 | ||
111 | if (child != null) { | 112 | if (child != null) { |
112 | final Matrix4 mat = Matrix4.identity(); | 113 | final Matrix4 mat = Matrix4.identity(); |
@@ -191,12 +192,7 @@ class Transform extends SingleChildWidget { | @@ -191,12 +192,7 @@ class Transform extends SingleChildWidget { | ||
191 | 192 | ||
192 | @override | 193 | @override |
193 | void paint(Context context) { | 194 | void paint(Context context) { |
194 | - assert(() { | ||
195 | - if (Document.debug) { | ||
196 | - debugPaint(context); | ||
197 | - } | ||
198 | - return true; | ||
199 | - }()); | 195 | + super.paint(context); |
200 | 196 | ||
201 | if (child != null) { | 197 | if (child != null) { |
202 | final Matrix4 mat = _effectiveTransform; | 198 | final Matrix4 mat = _effectiveTransform; |
@@ -258,6 +254,12 @@ class Align extends SingleChildWidget { | @@ -258,6 +254,12 @@ class Align extends SingleChildWidget { | ||
258 | height: shrinkWrapHeight ? 0.0 : double.infinity); | 254 | height: shrinkWrapHeight ? 0.0 : double.infinity); |
259 | } | 255 | } |
260 | } | 256 | } |
257 | + | ||
258 | + @override | ||
259 | + void paint(Context context) { | ||
260 | + super.paint(context); | ||
261 | + paintChild(context); | ||
262 | + } | ||
261 | } | 263 | } |
262 | 264 | ||
263 | /// A widget that imposes additional constraints on its child. | 265 | /// A widget that imposes additional constraints on its child. |
@@ -282,6 +284,12 @@ class ConstrainedBox extends SingleChildWidget { | @@ -282,6 +284,12 @@ class ConstrainedBox extends SingleChildWidget { | ||
282 | this.constraints.enforce(constraints).constrain(PdfPoint.zero)); | 284 | this.constraints.enforce(constraints).constrain(PdfPoint.zero)); |
283 | } | 285 | } |
284 | } | 286 | } |
287 | + | ||
288 | + @override | ||
289 | + void paint(Context context) { | ||
290 | + super.paint(context); | ||
291 | + paintChild(context); | ||
292 | + } | ||
285 | } | 293 | } |
286 | 294 | ||
287 | class Center extends Align { | 295 | class Center extends Align { |
@@ -323,6 +331,8 @@ class FittedBox extends SingleChildWidget { | @@ -323,6 +331,8 @@ class FittedBox extends SingleChildWidget { | ||
323 | 331 | ||
324 | @override | 332 | @override |
325 | void paint(Context context) { | 333 | void paint(Context context) { |
334 | + super.paint(context); | ||
335 | + | ||
326 | if (child != null) { | 336 | if (child != null) { |
327 | final PdfPoint childSize = child.box.size; | 337 | final PdfPoint childSize = child.box.size; |
328 | final FittedSizes sizes = applyBoxFit(fit, childSize, box.size); | 338 | final FittedSizes sizes = applyBoxFit(fit, childSize, box.size); |
@@ -404,6 +414,12 @@ class AspectRatio extends SingleChildWidget { | @@ -404,6 +414,12 @@ class AspectRatio extends SingleChildWidget { | ||
404 | BoxConstraints.tightFor(width: box.width, height: box.height)); | 414 | BoxConstraints.tightFor(width: box.width, height: box.height)); |
405 | assert(child.box != null); | 415 | assert(child.box != null); |
406 | } | 416 | } |
417 | + | ||
418 | + @override | ||
419 | + void paint(Context context) { | ||
420 | + super.paint(context); | ||
421 | + paintChild(context); | ||
422 | + } | ||
407 | } | 423 | } |
408 | 424 | ||
409 | typedef CustomPainter = Function(PdfGraphics canvas, PdfPoint size); | 425 | typedef CustomPainter = Function(PdfGraphics canvas, PdfPoint size); |
@@ -435,12 +451,7 @@ class CustomPaint extends SingleChildWidget { | @@ -435,12 +451,7 @@ class CustomPaint extends SingleChildWidget { | ||
435 | 451 | ||
436 | @override | 452 | @override |
437 | void paint(Context context) { | 453 | void paint(Context context) { |
438 | - assert(() { | ||
439 | - if (Document.debug) { | ||
440 | - debugPaint(context); | ||
441 | - } | ||
442 | - return true; | ||
443 | - }()); | 454 | + super.paint(context); |
444 | 455 | ||
445 | final Matrix4 mat = Matrix4.identity(); | 456 | final Matrix4 mat = Matrix4.identity(); |
446 | mat.translate(box.x, box.y); | 457 | mat.translate(box.x, box.y); |
@@ -29,12 +29,7 @@ class ClipRect extends SingleChildWidget { | @@ -29,12 +29,7 @@ class ClipRect extends SingleChildWidget { | ||
29 | 29 | ||
30 | @override | 30 | @override |
31 | void paint(Context context) { | 31 | void paint(Context context) { |
32 | - assert(() { | ||
33 | - if (Document.debug) { | ||
34 | - debugPaint(context); | ||
35 | - } | ||
36 | - return true; | ||
37 | - }()); | 32 | + super.paint(context); |
38 | 33 | ||
39 | if (child != null) { | 34 | if (child != null) { |
40 | final Matrix4 mat = Matrix4.identity(); | 35 | final Matrix4 mat = Matrix4.identity(); |
@@ -71,12 +66,7 @@ class ClipRRect extends SingleChildWidget { | @@ -71,12 +66,7 @@ class ClipRRect extends SingleChildWidget { | ||
71 | 66 | ||
72 | @override | 67 | @override |
73 | void paint(Context context) { | 68 | void paint(Context context) { |
74 | - assert(() { | ||
75 | - if (Document.debug) { | ||
76 | - debugPaint(context); | ||
77 | - } | ||
78 | - return true; | ||
79 | - }()); | 69 | + super.paint(context); |
80 | 70 | ||
81 | if (child != null) { | 71 | if (child != null) { |
82 | final Matrix4 mat = Matrix4.identity(); | 72 | final Matrix4 mat = Matrix4.identity(); |
@@ -109,12 +99,7 @@ class ClipOval extends SingleChildWidget { | @@ -109,12 +99,7 @@ class ClipOval extends SingleChildWidget { | ||
109 | 99 | ||
110 | @override | 100 | @override |
111 | void paint(Context context) { | 101 | void paint(Context context) { |
112 | - assert(() { | ||
113 | - if (Document.debug) { | ||
114 | - debugPaint(context); | ||
115 | - } | ||
116 | - return true; | ||
117 | - }()); | 102 | + super.paint(context); |
118 | 103 | ||
119 | final double rx = box.width / 2.0; | 104 | final double rx = box.width / 2.0; |
120 | final double ry = box.height / 2.0; | 105 | final double ry = box.height / 2.0; |
@@ -147,11 +147,12 @@ class DecoratedBox extends SingleChildWidget { | @@ -147,11 +147,12 @@ class DecoratedBox extends SingleChildWidget { | ||
147 | 147 | ||
148 | @override | 148 | @override |
149 | void paint(Context context) { | 149 | void paint(Context context) { |
150 | + super.paint(context); | ||
150 | if (position == DecorationPosition.background) { | 151 | if (position == DecorationPosition.background) { |
151 | decoration.paintBackground(context, box); | 152 | decoration.paintBackground(context, box); |
152 | decoration.border?.paintBorders(context, box); | 153 | decoration.border?.paintBorders(context, box); |
153 | } | 154 | } |
154 | - super.paint(context); | 155 | + paintChild(context); |
155 | if (position == DecorationPosition.foreground) { | 156 | if (position == DecorationPosition.foreground) { |
156 | decoration.paintBackground(context, box); | 157 | decoration.paintBackground(context, box); |
157 | decoration.border?.paintBorders(context, box); | 158 | decoration.border?.paintBorders(context, box); |
@@ -506,6 +506,12 @@ class Expanded extends SingleChildWidget { | @@ -506,6 +506,12 @@ class Expanded extends SingleChildWidget { | ||
506 | final int flex; | 506 | final int flex; |
507 | 507 | ||
508 | final FlexFit fit; | 508 | final FlexFit fit; |
509 | + | ||
510 | + @override | ||
511 | + void paint(Context context) { | ||
512 | + super.paint(context); | ||
513 | + paintChild(context); | ||
514 | + } | ||
509 | } | 515 | } |
510 | 516 | ||
511 | class ListView extends Flex { | 517 | class ListView extends Flex { |
@@ -44,6 +44,12 @@ class Positioned extends SingleChildWidget { | @@ -44,6 +44,12 @@ class Positioned extends SingleChildWidget { | ||
44 | double get width => box?.width; | 44 | double get width => box?.width; |
45 | 45 | ||
46 | double get height => box?.height; | 46 | double get height => box?.height; |
47 | + | ||
48 | + @override | ||
49 | + void paint(Context context) { | ||
50 | + super.paint(context); | ||
51 | + paintChild(context); | ||
52 | + } | ||
47 | } | 53 | } |
48 | 54 | ||
49 | /// A widget that positions its children relative to the edges of its box. | 55 | /// A widget that positions its children relative to the edges of its box. |
@@ -74,6 +74,7 @@ abstract class Widget { | @@ -74,6 +74,7 @@ abstract class Widget { | ||
74 | /// Draw itself and its children, according to the calculated | 74 | /// Draw itself and its children, according to the calculated |
75 | /// [box.offset] | 75 | /// [box.offset] |
76 | @protected | 76 | @protected |
77 | + @mustCallSuper | ||
77 | void paint(Context context) { | 78 | void paint(Context context) { |
78 | assert(() { | 79 | assert(() { |
79 | if (Document.debug) { | 80 | if (Document.debug) { |
@@ -147,10 +148,8 @@ abstract class SingleChildWidget extends Widget { | @@ -147,10 +148,8 @@ abstract class SingleChildWidget extends Widget { | ||
147 | } | 148 | } |
148 | } | 149 | } |
149 | 150 | ||
150 | - @override | ||
151 | - void paint(Context context) { | ||
152 | - super.paint(context); | ||
153 | - | 151 | + @protected |
152 | + void paintChild(Context context) { | ||
154 | if (child != null) { | 153 | if (child != null) { |
155 | final Matrix4 mat = Matrix4.identity(); | 154 | final Matrix4 mat = Matrix4.identity(); |
156 | mat.translate(box.x, box.y); | 155 | mat.translate(box.x, box.y); |
-
Please register or login to post a comment