Showing
7 changed files
with
36 additions
and
22 deletions
@@ -133,9 +133,9 @@ class PdfAnnot extends PdfObject { | @@ -133,9 +133,9 @@ class PdfAnnot extends PdfObject { | ||
133 | } else { | 133 | } else { |
134 | final List<PdfStream> dests = <PdfStream>[]; | 134 | final List<PdfStream> dests = <PdfStream>[]; |
135 | dests.add(dest.ref()); | 135 | dests.add(dest.ref()); |
136 | - if (destRect == null) | 136 | + if (destRect == null) { |
137 | dests.add(PdfStream.string('/Fit')); | 137 | dests.add(PdfStream.string('/Fit')); |
138 | - else { | 138 | + } else { |
139 | dests.add(PdfStream.string('/FitR ')); | 139 | dests.add(PdfStream.string('/FitR ')); |
140 | dests.add(PdfStream() | 140 | dests.add(PdfStream() |
141 | ..putNumList(<double>[ | 141 | ..putNumList(<double>[ |
@@ -108,8 +108,9 @@ class PdfOutput { | @@ -108,8 +108,9 @@ class PdfOutput { | ||
108 | os.putString('/Root '); | 108 | os.putString('/Root '); |
109 | os.putStream(rootID.ref()); | 109 | os.putStream(rootID.ref()); |
110 | os.putString('\n'); | 110 | os.putString('\n'); |
111 | - } else | 111 | + } else { |
112 | throw Exception('Root object is not present in document'); | 112 | throw Exception('Root object is not present in document'); |
113 | + } | ||
113 | 114 | ||
114 | // the /Info reference (OPTIONAL) | 115 | // the /Info reference (OPTIONAL) |
115 | if (infoID != null) { | 116 | if (infoID != null) { |
@@ -410,9 +410,10 @@ class AspectRatio extends SingleChildWidget { | @@ -410,9 +410,10 @@ class AspectRatio extends SingleChildWidget { | ||
410 | void layout(Context context, BoxConstraints constraints, | 410 | void layout(Context context, BoxConstraints constraints, |
411 | {bool parentUsesSize = false}) { | 411 | {bool parentUsesSize = false}) { |
412 | box = PdfRect.fromPoints(PdfPoint.zero, _applyAspectRatio(constraints)); | 412 | box = PdfRect.fromPoints(PdfPoint.zero, _applyAspectRatio(constraints)); |
413 | - if (child != null) | 413 | + if (child != null) { |
414 | child.layout(context, | 414 | child.layout(context, |
415 | BoxConstraints.tightFor(width: box.width, height: box.height)); | 415 | BoxConstraints.tightFor(width: box.width, height: box.height)); |
416 | + } | ||
416 | assert(child.box != null); | 417 | assert(child.box != null); |
417 | } | 418 | } |
418 | 419 |
@@ -77,9 +77,10 @@ class BoxBorder { | @@ -77,9 +77,10 @@ class BoxBorder { | ||
77 | context.canvas.lineTo(box.x, box.top); | 77 | context.canvas.lineTo(box.x, box.top); |
78 | } else if (right && top) { | 78 | } else if (right && top) { |
79 | context.canvas.closePath(); | 79 | context.canvas.closePath(); |
80 | - } else | 80 | + } else { |
81 | context.canvas.lineTo(box.x, box.top); | 81 | context.canvas.lineTo(box.x, box.top); |
82 | } | 82 | } |
83 | + } | ||
83 | 84 | ||
84 | context.canvas.strokePath(); | 85 | context.canvas.strokePath(); |
85 | } | 86 | } |
@@ -151,12 +152,12 @@ class BoxDecoration { | @@ -151,12 +152,12 @@ class BoxDecoration { | ||
151 | if (color != null) { | 152 | if (color != null) { |
152 | switch (shape) { | 153 | switch (shape) { |
153 | case BoxShape.rectangle: | 154 | case BoxShape.rectangle: |
154 | - if (borderRadius == null) | 155 | + if (borderRadius == null) { |
155 | context.canvas.drawRect(box.x, box.y, box.width, box.height); | 156 | context.canvas.drawRect(box.x, box.y, box.width, box.height); |
156 | - else | 157 | + } else { |
157 | context.canvas.drawRRect(box.x, box.y, box.width, box.height, | 158 | context.canvas.drawRRect(box.x, box.y, box.width, box.height, |
158 | borderRadius, borderRadius); | 159 | borderRadius, borderRadius); |
159 | - | 160 | + } |
160 | break; | 161 | break; |
161 | case BoxShape.circle: | 162 | case BoxShape.circle: |
162 | context.canvas.drawEllipse(box.x + box.width / 2.0, | 163 | context.canvas.drawEllipse(box.x + box.width / 2.0, |
@@ -259,15 +260,17 @@ class Container extends StatelessWidget { | @@ -259,15 +260,17 @@ class Container extends StatelessWidget { | ||
259 | child: ConstrainedBox(constraints: const BoxConstraints.expand())); | 260 | child: ConstrainedBox(constraints: const BoxConstraints.expand())); |
260 | } | 261 | } |
261 | 262 | ||
262 | - if (alignment != null) | 263 | + if (alignment != null) { |
263 | current = Align(alignment: alignment, child: current); | 264 | current = Align(alignment: alignment, child: current); |
265 | + } | ||
264 | 266 | ||
265 | if (padding != null) { | 267 | if (padding != null) { |
266 | current = Padding(padding: padding, child: current); | 268 | current = Padding(padding: padding, child: current); |
267 | } | 269 | } |
268 | 270 | ||
269 | - if (decoration != null) | 271 | + if (decoration != null) { |
270 | current = DecoratedBox(decoration: decoration, child: current); | 272 | current = DecoratedBox(decoration: decoration, child: current); |
273 | + } | ||
271 | 274 | ||
272 | if (foregroundDecoration != null) { | 275 | if (foregroundDecoration != null) { |
273 | current = DecoratedBox( | 276 | current = DecoratedBox( |
@@ -276,15 +279,17 @@ class Container extends StatelessWidget { | @@ -276,15 +279,17 @@ class Container extends StatelessWidget { | ||
276 | child: current); | 279 | child: current); |
277 | } | 280 | } |
278 | 281 | ||
279 | - if (constraints != null) | 282 | + if (constraints != null) { |
280 | current = ConstrainedBox(constraints: constraints, child: current); | 283 | current = ConstrainedBox(constraints: constraints, child: current); |
284 | + } | ||
281 | 285 | ||
282 | if (margin != null) { | 286 | if (margin != null) { |
283 | current = Padding(padding: margin, child: current); | 287 | current = Padding(padding: margin, child: current); |
284 | } | 288 | } |
285 | 289 | ||
286 | - if (transform != null) | 290 | + if (transform != null) { |
287 | current = Transform(transform: transform, child: current); | 291 | current = Transform(transform: transform, child: current); |
292 | + } | ||
288 | 293 | ||
289 | return current; | 294 | return current; |
290 | } | 295 | } |
@@ -144,10 +144,11 @@ class Flex extends MultiChildWidget { | @@ -144,10 +144,11 @@ class Flex extends MultiChildWidget { | ||
144 | // Size remaining (flexible) items, find the maximum cross size. | 144 | // Size remaining (flexible) items, find the maximum cross size. |
145 | for (Widget child in children) { | 145 | for (Widget child in children) { |
146 | final int flex = child is Expanded ? child.flex : 0; | 146 | final int flex = child is Expanded ? child.flex : 0; |
147 | - if (flex > 0) | 147 | + if (flex > 0) { |
148 | maxCrossSize = | 148 | maxCrossSize = |
149 | math.max(maxCrossSize, childSize(child, spacePerFlex * flex)); | 149 | math.max(maxCrossSize, childSize(child, spacePerFlex * flex)); |
150 | } | 150 | } |
151 | + } | ||
151 | 152 | ||
152 | return maxCrossSize; | 153 | return maxCrossSize; |
153 | } | 154 | } |
@@ -359,8 +359,9 @@ FittedSizes applyBoxFit(BoxFit fit, PdfPoint inputSize, PdfPoint outputSize) { | @@ -359,8 +359,9 @@ FittedSizes applyBoxFit(BoxFit fit, PdfPoint inputSize, PdfPoint outputSize) { | ||
359 | if (inputSize.y <= 0.0 || | 359 | if (inputSize.y <= 0.0 || |
360 | inputSize.x <= 0.0 || | 360 | inputSize.x <= 0.0 || |
361 | outputSize.y <= 0.0 || | 361 | outputSize.y <= 0.0 || |
362 | - outputSize.x <= 0.0) | 362 | + outputSize.x <= 0.0) { |
363 | return const FittedSizes(PdfPoint.zero, PdfPoint.zero); | 363 | return const FittedSizes(PdfPoint.zero, PdfPoint.zero); |
364 | + } | ||
364 | 365 | ||
365 | PdfPoint sourceSize, destinationSize; | 366 | PdfPoint sourceSize, destinationSize; |
366 | switch (fit) { | 367 | switch (fit) { |
@@ -370,12 +371,13 @@ FittedSizes applyBoxFit(BoxFit fit, PdfPoint inputSize, PdfPoint outputSize) { | @@ -370,12 +371,13 @@ FittedSizes applyBoxFit(BoxFit fit, PdfPoint inputSize, PdfPoint outputSize) { | ||
370 | break; | 371 | break; |
371 | case BoxFit.contain: | 372 | case BoxFit.contain: |
372 | sourceSize = inputSize; | 373 | sourceSize = inputSize; |
373 | - if (outputSize.x / outputSize.y > sourceSize.x / sourceSize.y) | 374 | + if (outputSize.x / outputSize.y > sourceSize.x / sourceSize.y) { |
374 | destinationSize = | 375 | destinationSize = |
375 | PdfPoint(sourceSize.x * outputSize.y / sourceSize.y, outputSize.y); | 376 | PdfPoint(sourceSize.x * outputSize.y / sourceSize.y, outputSize.y); |
376 | - else | 377 | + } else { |
377 | destinationSize = | 378 | destinationSize = |
378 | PdfPoint(outputSize.x, sourceSize.y * outputSize.x / sourceSize.x); | 379 | PdfPoint(outputSize.x, sourceSize.y * outputSize.x / sourceSize.x); |
380 | + } | ||
379 | break; | 381 | break; |
380 | case BoxFit.cover: | 382 | case BoxFit.cover: |
381 | if (outputSize.x / outputSize.y > inputSize.x / inputSize.y) { | 383 | if (outputSize.x / outputSize.y > inputSize.x / inputSize.y) { |
@@ -408,10 +410,12 @@ FittedSizes applyBoxFit(BoxFit fit, PdfPoint inputSize, PdfPoint outputSize) { | @@ -408,10 +410,12 @@ FittedSizes applyBoxFit(BoxFit fit, PdfPoint inputSize, PdfPoint outputSize) { | ||
408 | sourceSize = inputSize; | 410 | sourceSize = inputSize; |
409 | destinationSize = inputSize; | 411 | destinationSize = inputSize; |
410 | final double aspectRatio = inputSize.x / inputSize.y; | 412 | final double aspectRatio = inputSize.x / inputSize.y; |
411 | - if (destinationSize.y > outputSize.y) | 413 | + if (destinationSize.y > outputSize.y) { |
412 | destinationSize = PdfPoint(outputSize.y * aspectRatio, outputSize.y); | 414 | destinationSize = PdfPoint(outputSize.y * aspectRatio, outputSize.y); |
413 | - if (destinationSize.x > outputSize.x) | 415 | + } |
416 | + if (destinationSize.x > outputSize.x) { | ||
414 | destinationSize = PdfPoint(outputSize.x, outputSize.x / aspectRatio); | 417 | destinationSize = PdfPoint(outputSize.x, outputSize.x / aspectRatio); |
418 | + } | ||
415 | break; | 419 | break; |
416 | } | 420 | } |
417 | return FittedSizes(sourceSize, destinationSize); | 421 | return FittedSizes(sourceSize, destinationSize); |
@@ -130,18 +130,20 @@ class Stack extends MultiChildWidget { | @@ -130,18 +130,20 @@ class Stack extends MultiChildWidget { | ||
130 | final Positioned positioned = child; | 130 | final Positioned positioned = child; |
131 | BoxConstraints childConstraints = const BoxConstraints(); | 131 | BoxConstraints childConstraints = const BoxConstraints(); |
132 | 132 | ||
133 | - if (positioned.left != null && positioned.right != null) | 133 | + if (positioned.left != null && positioned.right != null) { |
134 | childConstraints = childConstraints.tighten( | 134 | childConstraints = childConstraints.tighten( |
135 | width: box.width - positioned.right - positioned.left); | 135 | width: box.width - positioned.right - positioned.left); |
136 | - else if (positioned.width != null) | 136 | + } else if (positioned.width != null) { |
137 | childConstraints = childConstraints.tighten(width: positioned.width); | 137 | childConstraints = childConstraints.tighten(width: positioned.width); |
138 | + } | ||
138 | 139 | ||
139 | - if (positioned.top != null && positioned.bottom != null) | 140 | + if (positioned.top != null && positioned.bottom != null) { |
140 | childConstraints = childConstraints.tighten( | 141 | childConstraints = childConstraints.tighten( |
141 | height: box.height - positioned.bottom - positioned.top); | 142 | height: box.height - positioned.bottom - positioned.top); |
142 | - else if (positioned.height != null) | 143 | + } else if (positioned.height != null) { |
143 | childConstraints = | 144 | childConstraints = |
144 | childConstraints.tighten(height: positioned.height); | 145 | childConstraints.tighten(height: positioned.height); |
146 | + } | ||
145 | 147 | ||
146 | positioned.layout(context, childConstraints, parentUsesSize: true); | 148 | positioned.layout(context, childConstraints, parentUsesSize: true); |
147 | assert(positioned.box != null); | 149 | assert(positioned.box != null); |
-
Please register or login to post a comment