Showing
18 changed files
with
580 additions
and
280 deletions
@@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
4 | 4 | ||
5 | - Improve TTF writer with multi-compound characters | 5 | - Improve TTF writer with multi-compound characters |
6 | - Partially revert underline on spans changes | 6 | - Partially revert underline on spans changes |
7 | +- Add RTL support [Milad-Akarie] | ||
7 | 8 | ||
8 | ## 3.10.4 | 9 | ## 3.10.4 |
9 | 10 |
@@ -22,7 +22,8 @@ import 'point.dart'; | @@ -22,7 +22,8 @@ import 'point.dart'; | ||
22 | class PdfRect { | 22 | class PdfRect { |
23 | const PdfRect(this.x, this.y, this.width, this.height); | 23 | const PdfRect(this.x, this.y, this.width, this.height); |
24 | 24 | ||
25 | - factory PdfRect.fromLTRB(double left, double top, double right, double bottom) { | 25 | + factory PdfRect.fromLTRB( |
26 | + double left, double top, double right, double bottom) { | ||
26 | return PdfRect(left, top, right - left, bottom - top); | 27 | return PdfRect(left, top, right - left, bottom - top); |
27 | } | 28 | } |
28 | 29 | ||
@@ -70,7 +71,8 @@ class PdfRect { | @@ -70,7 +71,8 @@ class PdfRect { | ||
70 | 71 | ||
71 | /// Returns a new rectangle with edges moved outwards by the given delta. | 72 | /// Returns a new rectangle with edges moved outwards by the given delta. |
72 | PdfRect inflate(double delta) { | 73 | PdfRect inflate(double delta) { |
73 | - return PdfRect.fromLTRB(left - delta, top - delta, right + delta, bottom + delta); | 74 | + return PdfRect.fromLTRB( |
75 | + left - delta, top - delta, right + delta, bottom + delta); | ||
74 | } | 76 | } |
75 | 77 | ||
76 | /// Returns a new rectangle with edges moved inwards by the given delta. | 78 | /// Returns a new rectangle with edges moved inwards by the given delta. |
@@ -39,16 +39,22 @@ class LimitedBox extends SingleChildWidget { | @@ -39,16 +39,22 @@ class LimitedBox extends SingleChildWidget { | ||
39 | BoxConstraints _limitConstraints(BoxConstraints constraints) { | 39 | BoxConstraints _limitConstraints(BoxConstraints constraints) { |
40 | return BoxConstraints( | 40 | return BoxConstraints( |
41 | minWidth: constraints.minWidth, | 41 | minWidth: constraints.minWidth, |
42 | - maxWidth: constraints.hasBoundedWidth ? constraints.maxWidth : constraints.constrainWidth(maxWidth), | 42 | + maxWidth: constraints.hasBoundedWidth |
43 | + ? constraints.maxWidth | ||
44 | + : constraints.constrainWidth(maxWidth), | ||
43 | minHeight: constraints.minHeight, | 45 | minHeight: constraints.minHeight, |
44 | - maxHeight: constraints.hasBoundedHeight ? constraints.maxHeight : constraints.constrainHeight(maxHeight)); | 46 | + maxHeight: constraints.hasBoundedHeight |
47 | + ? constraints.maxHeight | ||
48 | + : constraints.constrainHeight(maxHeight)); | ||
45 | } | 49 | } |
46 | 50 | ||
47 | @override | 51 | @override |
48 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 52 | + void layout(Context context, BoxConstraints constraints, |
53 | + {bool parentUsesSize = false}) { | ||
49 | PdfPoint size; | 54 | PdfPoint size; |
50 | if (child != null) { | 55 | if (child != null) { |
51 | - child!.layout(context, _limitConstraints(constraints), parentUsesSize: true); | 56 | + child!.layout(context, _limitConstraints(constraints), |
57 | + parentUsesSize: true); | ||
52 | assert(child!.box != null); | 58 | assert(child!.box != null); |
53 | size = constraints.constrain(child!.box!.size); | 59 | size = constraints.constrain(child!.box!.size); |
54 | } else { | 60 | } else { |
@@ -73,16 +79,19 @@ class Padding extends SingleChildWidget { | @@ -73,16 +79,19 @@ class Padding extends SingleChildWidget { | ||
73 | final EdgeInsetsGeometry padding; | 79 | final EdgeInsetsGeometry padding; |
74 | 80 | ||
75 | @override | 81 | @override |
76 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 82 | + void layout(Context context, BoxConstraints constraints, |
83 | + {bool parentUsesSize = false}) { | ||
77 | final resolvedPadding = padding.resolve(Directionality.of(context)); | 84 | final resolvedPadding = padding.resolve(Directionality.of(context)); |
78 | if (child != null) { | 85 | if (child != null) { |
79 | final childConstraints = constraints.deflate(resolvedPadding); | 86 | final childConstraints = constraints.deflate(resolvedPadding); |
80 | child!.layout(context, childConstraints, parentUsesSize: parentUsesSize); | 87 | child!.layout(context, childConstraints, parentUsesSize: parentUsesSize); |
81 | assert(child!.box != null); | 88 | assert(child!.box != null); |
82 | box = constraints.constrainRect( | 89 | box = constraints.constrainRect( |
83 | - width: child!.box!.width + resolvedPadding.horizontal, height: child!.box!.height + resolvedPadding.vertical); | 90 | + width: child!.box!.width + resolvedPadding.horizontal, |
91 | + height: child!.box!.height + resolvedPadding.vertical); | ||
84 | } else { | 92 | } else { |
85 | - box = constraints.constrainRect(width: resolvedPadding.horizontal, height: resolvedPadding.vertical); | 93 | + box = constraints.constrainRect( |
94 | + width: resolvedPadding.horizontal, height: resolvedPadding.vertical); | ||
86 | } | 95 | } |
87 | } | 96 | } |
88 | 97 | ||
@@ -97,8 +106,10 @@ class Padding extends SingleChildWidget { | @@ -97,8 +106,10 @@ class Padding extends SingleChildWidget { | ||
97 | ..lineTo(box!.x, box!.top) | 106 | ..lineTo(box!.x, box!.top) |
98 | ..moveTo(box!.x + resolvedPadding.left, box!.y + resolvedPadding.bottom) | 107 | ..moveTo(box!.x + resolvedPadding.left, box!.y + resolvedPadding.bottom) |
99 | ..lineTo(box!.x + resolvedPadding.left, box!.top - resolvedPadding.top) | 108 | ..lineTo(box!.x + resolvedPadding.left, box!.top - resolvedPadding.top) |
100 | - ..lineTo(box!.right - resolvedPadding.right, box!.top - resolvedPadding.top) | ||
101 | - ..lineTo(box!.right - resolvedPadding.right, box!.y + resolvedPadding.bottom) | 109 | + ..lineTo( |
110 | + box!.right - resolvedPadding.right, box!.top - resolvedPadding.top) | ||
111 | + ..lineTo( | ||
112 | + box!.right - resolvedPadding.right, box!.y + resolvedPadding.bottom) | ||
102 | ..fillPath(); | 113 | ..fillPath(); |
103 | } | 114 | } |
104 | 115 | ||
@@ -108,7 +119,8 @@ class Padding extends SingleChildWidget { | @@ -108,7 +119,8 @@ class Padding extends SingleChildWidget { | ||
108 | final resolvedPadding = padding.resolve(Directionality.of(context)); | 119 | final resolvedPadding = padding.resolve(Directionality.of(context)); |
109 | if (child != null) { | 120 | if (child != null) { |
110 | final mat = Matrix4.identity(); | 121 | final mat = Matrix4.identity(); |
111 | - mat.translate(box!.x + resolvedPadding.left, box!.y + resolvedPadding.bottom); | 122 | + mat.translate( |
123 | + box!.x + resolvedPadding.left, box!.y + resolvedPadding.bottom); | ||
112 | context.canvas | 124 | context.canvas |
113 | ..saveContext() | 125 | ..saveContext() |
114 | ..setTransform(mat); | 126 | ..setTransform(mat); |
@@ -210,7 +222,8 @@ class Transform extends SingleChildWidget { | @@ -210,7 +222,8 @@ class Transform extends SingleChildWidget { | ||
210 | } | 222 | } |
211 | 223 | ||
212 | @override | 224 | @override |
213 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 225 | + void layout(Context context, BoxConstraints constraints, |
226 | + {bool parentUsesSize = false}) { | ||
214 | if (!adjustLayout) { | 227 | if (!adjustLayout) { |
215 | return super.layout(context, constraints, parentUsesSize: parentUsesSize); | 228 | return super.layout(context, constraints, parentUsesSize: parentUsesSize); |
216 | } | 229 | } |
@@ -239,14 +252,20 @@ class Transform extends SingleChildWidget { | @@ -239,14 +252,20 @@ class Transform extends SingleChildWidget { | ||
239 | 0, | 252 | 0, |
240 | ]); | 253 | ]); |
241 | 254 | ||
242 | - final dx = -math.min(math.min(math.min(values[0], values[3]), values[6]), values[9]); | ||
243 | - final dy = -math.min(math.min(math.min(values[1], values[4]), values[7]), values[10]); | 255 | + final dx = -math.min( |
256 | + math.min(math.min(values[0], values[3]), values[6]), values[9]); | ||
257 | + final dy = -math.min( | ||
258 | + math.min(math.min(values[1], values[4]), values[7]), values[10]); | ||
244 | 259 | ||
245 | box = PdfRect.fromLTRB( | 260 | box = PdfRect.fromLTRB( |
246 | 0, | 261 | 0, |
247 | 0, | 262 | 0, |
248 | - math.max(math.max(math.max(values[0], values[3]), values[6]), values[9]) + dx, | ||
249 | - math.max(math.max(math.max(values[1], values[4]), values[7]), values[10]) + dy, | 263 | + math.max(math.max(math.max(values[0], values[3]), values[6]), |
264 | + values[9]) + | ||
265 | + dx, | ||
266 | + math.max(math.max(math.max(values[1], values[4]), values[7]), | ||
267 | + values[10]) + | ||
268 | + dy, | ||
250 | ); | 269 | ); |
251 | 270 | ||
252 | transform.leftTranslate(dx, dy); | 271 | transform.leftTranslate(dx, dy); |
@@ -273,7 +292,11 @@ class Transform extends SingleChildWidget { | @@ -273,7 +292,11 @@ class Transform extends SingleChildWidget { | ||
273 | /// A widget that aligns its child within itself and optionally sizes itself | 292 | /// A widget that aligns its child within itself and optionally sizes itself |
274 | /// based on the child's size. | 293 | /// based on the child's size. |
275 | class Align extends SingleChildWidget { | 294 | class Align extends SingleChildWidget { |
276 | - Align({this.alignment = Alignment.center, this.widthFactor, this.heightFactor, Widget? child}) | 295 | + Align( |
296 | + {this.alignment = Alignment.center, | ||
297 | + this.widthFactor, | ||
298 | + this.heightFactor, | ||
299 | + Widget? child}) | ||
277 | : assert(widthFactor == null || widthFactor >= 0.0), | 300 | : assert(widthFactor == null || widthFactor >= 0.0), |
278 | assert(heightFactor == null || heightFactor >= 0.0), | 301 | assert(heightFactor == null || heightFactor >= 0.0), |
279 | super(child: child); | 302 | super(child: child); |
@@ -288,22 +311,30 @@ class Align extends SingleChildWidget { | @@ -288,22 +311,30 @@ class Align extends SingleChildWidget { | ||
288 | final double? heightFactor; | 311 | final double? heightFactor; |
289 | 312 | ||
290 | @override | 313 | @override |
291 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | ||
292 | - final shrinkWrapWidth = widthFactor != null || constraints.maxWidth == double.infinity; | ||
293 | - final shrinkWrapHeight = heightFactor != null || constraints.maxHeight == double.infinity; | 314 | + void layout(Context context, BoxConstraints constraints, |
315 | + {bool parentUsesSize = false}) { | ||
316 | + final shrinkWrapWidth = | ||
317 | + widthFactor != null || constraints.maxWidth == double.infinity; | ||
318 | + final shrinkWrapHeight = | ||
319 | + heightFactor != null || constraints.maxHeight == double.infinity; | ||
294 | 320 | ||
295 | if (child != null) { | 321 | if (child != null) { |
296 | child!.layout(context, constraints.loosen(), parentUsesSize: true); | 322 | child!.layout(context, constraints.loosen(), parentUsesSize: true); |
297 | assert(child!.box != null); | 323 | assert(child!.box != null); |
298 | 324 | ||
299 | box = constraints.constrainRect( | 325 | box = constraints.constrainRect( |
300 | - width: shrinkWrapWidth ? child!.box!.width * (widthFactor ?? 1.0) : double.infinity, | ||
301 | - height: shrinkWrapHeight ? child!.box!.height * (heightFactor ?? 1.0) : double.infinity); | 326 | + width: shrinkWrapWidth |
327 | + ? child!.box!.width * (widthFactor ?? 1.0) | ||
328 | + : double.infinity, | ||
329 | + height: shrinkWrapHeight | ||
330 | + ? child!.box!.height * (heightFactor ?? 1.0) | ||
331 | + : double.infinity); | ||
302 | final resolvedAlignment = alignment.resolve(Directionality.of(context)); | 332 | final resolvedAlignment = alignment.resolve(Directionality.of(context)); |
303 | child!.box = resolvedAlignment.inscribe(child!.box!.size, box!); | 333 | child!.box = resolvedAlignment.inscribe(child!.box!.size, box!); |
304 | } else { | 334 | } else { |
305 | box = constraints.constrainRect( | 335 | box = constraints.constrainRect( |
306 | - width: shrinkWrapWidth ? 0.0 : double.infinity, height: shrinkWrapHeight ? 0.0 : double.infinity); | 336 | + width: shrinkWrapWidth ? 0.0 : double.infinity, |
337 | + height: shrinkWrapHeight ? 0.0 : double.infinity); | ||
307 | } | 338 | } |
308 | } | 339 | } |
309 | 340 | ||
@@ -326,40 +357,58 @@ class Align extends SingleChildWidget { | @@ -326,40 +357,58 @@ class Align extends SingleChildWidget { | ||
326 | box!.left + child!.box!.horizontalCenter, | 357 | box!.left + child!.box!.horizontalCenter, |
327 | box!.bottom, | 358 | box!.bottom, |
328 | ) | 359 | ) |
329 | - ..lineTo(box!.left + child!.box!.horizontalCenter, box!.bottom + child!.box!.bottom) | ||
330 | - ..lineTo(box!.left + child!.box!.horizontalCenter - headSize, box!.bottom + child!.box!.bottom - headSize) | ||
331 | - ..moveTo(box!.left + child!.box!.horizontalCenter, box!.bottom + child!.box!.bottom) | ||
332 | - ..lineTo(box!.left + child!.box!.horizontalCenter + headSize, box!.bottom + child!.box!.bottom - headSize); | 360 | + ..lineTo(box!.left + child!.box!.horizontalCenter, |
361 | + box!.bottom + child!.box!.bottom) | ||
362 | + ..lineTo(box!.left + child!.box!.horizontalCenter - headSize, | ||
363 | + box!.bottom + child!.box!.bottom - headSize) | ||
364 | + ..moveTo(box!.left + child!.box!.horizontalCenter, | ||
365 | + box!.bottom + child!.box!.bottom) | ||
366 | + ..lineTo(box!.left + child!.box!.horizontalCenter + headSize, | ||
367 | + box!.bottom + child!.box!.bottom - headSize); | ||
333 | } | 368 | } |
334 | 369 | ||
335 | if (box!.bottom + child!.box!.top < box!.top) { | 370 | if (box!.bottom + child!.box!.top < box!.top) { |
336 | - final headSize = math.min((box!.top - child!.box!.top - box!.bottom) * 0.2, 10); | 371 | + final headSize = |
372 | + math.min((box!.top - child!.box!.top - box!.bottom) * 0.2, 10); | ||
337 | context.canvas | 373 | context.canvas |
338 | ..moveTo(box!.left + child!.box!.horizontalCenter, box!.top) | 374 | ..moveTo(box!.left + child!.box!.horizontalCenter, box!.top) |
339 | - ..lineTo(box!.left + child!.box!.horizontalCenter, box!.bottom + child!.box!.top) | ||
340 | - ..lineTo(box!.left + child!.box!.horizontalCenter - headSize, box!.bottom + child!.box!.top + headSize) | ||
341 | - ..moveTo(box!.left + child!.box!.horizontalCenter, box!.bottom + child!.box!.top) | ||
342 | - ..lineTo(box!.left + child!.box!.horizontalCenter + headSize, box!.bottom + child!.box!.top + headSize); | 375 | + ..lineTo(box!.left + child!.box!.horizontalCenter, |
376 | + box!.bottom + child!.box!.top) | ||
377 | + ..lineTo(box!.left + child!.box!.horizontalCenter - headSize, | ||
378 | + box!.bottom + child!.box!.top + headSize) | ||
379 | + ..moveTo(box!.left + child!.box!.horizontalCenter, | ||
380 | + box!.bottom + child!.box!.top) | ||
381 | + ..lineTo(box!.left + child!.box!.horizontalCenter + headSize, | ||
382 | + box!.bottom + child!.box!.top + headSize); | ||
343 | } | 383 | } |
344 | 384 | ||
345 | if (child!.box!.left > 0) { | 385 | if (child!.box!.left > 0) { |
346 | final headSize = math.min(child!.box!.left * 0.2, 10); | 386 | final headSize = math.min(child!.box!.left * 0.2, 10); |
347 | context.canvas | 387 | context.canvas |
348 | ..moveTo(box!.left, box!.bottom + child!.box!.verticalCenter) | 388 | ..moveTo(box!.left, box!.bottom + child!.box!.verticalCenter) |
349 | - ..lineTo(box!.left + child!.box!.left, box!.bottom + child!.box!.verticalCenter) | ||
350 | - ..lineTo(box!.left + child!.box!.left - headSize, box!.bottom + child!.box!.verticalCenter - headSize) | ||
351 | - ..moveTo(box!.left + child!.box!.left, box!.bottom + child!.box!.verticalCenter) | ||
352 | - ..lineTo(box!.left + child!.box!.left - headSize, box!.bottom + child!.box!.verticalCenter + headSize); | 389 | + ..lineTo(box!.left + child!.box!.left, |
390 | + box!.bottom + child!.box!.verticalCenter) | ||
391 | + ..lineTo(box!.left + child!.box!.left - headSize, | ||
392 | + box!.bottom + child!.box!.verticalCenter - headSize) | ||
393 | + ..moveTo(box!.left + child!.box!.left, | ||
394 | + box!.bottom + child!.box!.verticalCenter) | ||
395 | + ..lineTo(box!.left + child!.box!.left - headSize, | ||
396 | + box!.bottom + child!.box!.verticalCenter + headSize); | ||
353 | } | 397 | } |
354 | 398 | ||
355 | if (box!.left + child!.box!.right < box!.right) { | 399 | if (box!.left + child!.box!.right < box!.right) { |
356 | - final headSize = math.min((box!.right - child!.box!.right - box!.left) * 0.2, 10); | 400 | + final headSize = |
401 | + math.min((box!.right - child!.box!.right - box!.left) * 0.2, 10); | ||
357 | context.canvas | 402 | context.canvas |
358 | ..moveTo(box!.right, box!.bottom + child!.box!.verticalCenter) | 403 | ..moveTo(box!.right, box!.bottom + child!.box!.verticalCenter) |
359 | - ..lineTo(box!.left + child!.box!.right, box!.bottom + child!.box!.verticalCenter) | ||
360 | - ..lineTo(box!.left + child!.box!.right + headSize, box!.bottom + child!.box!.verticalCenter - headSize) | ||
361 | - ..moveTo(box!.left + child!.box!.right, box!.bottom + child!.box!.verticalCenter) | ||
362 | - ..lineTo(box!.left + child!.box!.right + headSize, box!.bottom + child!.box!.verticalCenter + headSize); | 404 | + ..lineTo(box!.left + child!.box!.right, |
405 | + box!.bottom + child!.box!.verticalCenter) | ||
406 | + ..lineTo(box!.left + child!.box!.right + headSize, | ||
407 | + box!.bottom + child!.box!.verticalCenter - headSize) | ||
408 | + ..moveTo(box!.left + child!.box!.right, | ||
409 | + box!.bottom + child!.box!.verticalCenter) | ||
410 | + ..lineTo(box!.left + child!.box!.right + headSize, | ||
411 | + box!.bottom + child!.box!.verticalCenter + headSize); | ||
363 | } | 412 | } |
364 | 413 | ||
365 | context.canvas.strokePath(); | 414 | context.canvas.strokePath(); |
@@ -374,19 +423,23 @@ class Align extends SingleChildWidget { | @@ -374,19 +423,23 @@ class Align extends SingleChildWidget { | ||
374 | 423 | ||
375 | /// A widget that imposes additional constraints on its child. | 424 | /// A widget that imposes additional constraints on its child. |
376 | class ConstrainedBox extends SingleChildWidget { | 425 | class ConstrainedBox extends SingleChildWidget { |
377 | - ConstrainedBox({required this.constraints, Widget? child}) : super(child: child); | 426 | + ConstrainedBox({required this.constraints, Widget? child}) |
427 | + : super(child: child); | ||
378 | 428 | ||
379 | /// The additional constraints to impose on the child. | 429 | /// The additional constraints to impose on the child. |
380 | final BoxConstraints constraints; | 430 | final BoxConstraints constraints; |
381 | 431 | ||
382 | @override | 432 | @override |
383 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 433 | + void layout(Context context, BoxConstraints constraints, |
434 | + {bool parentUsesSize = false}) { | ||
384 | if (child != null) { | 435 | if (child != null) { |
385 | - child!.layout(context, this.constraints.enforce(constraints), parentUsesSize: true); | 436 | + child!.layout(context, this.constraints.enforce(constraints), |
437 | + parentUsesSize: true); | ||
386 | assert(child!.box != null); | 438 | assert(child!.box != null); |
387 | box = child!.box; | 439 | box = child!.box; |
388 | } else { | 440 | } else { |
389 | - box = PdfRect.fromPoints(PdfPoint.zero, this.constraints.enforce(constraints).smallest); | 441 | + box = PdfRect.fromPoints( |
442 | + PdfPoint.zero, this.constraints.enforce(constraints).smallest); | ||
390 | } | 443 | } |
391 | } | 444 | } |
392 | 445 | ||
@@ -399,7 +452,8 @@ class ConstrainedBox extends SingleChildWidget { | @@ -399,7 +452,8 @@ class ConstrainedBox extends SingleChildWidget { | ||
399 | 452 | ||
400 | class Center extends Align { | 453 | class Center extends Align { |
401 | Center({double? widthFactor, double? heightFactor, Widget? child}) | 454 | Center({double? widthFactor, double? heightFactor, Widget? child}) |
402 | - : super(widthFactor: widthFactor, heightFactor: heightFactor, child: child); | 455 | + : super( |
456 | + widthFactor: widthFactor, heightFactor: heightFactor, child: child); | ||
403 | } | 457 | } |
404 | 458 | ||
405 | /// Scales and positions its child within itself according to [fit]. | 459 | /// Scales and positions its child within itself according to [fit]. |
@@ -417,12 +471,14 @@ class FittedBox extends SingleChildWidget { | @@ -417,12 +471,14 @@ class FittedBox extends SingleChildWidget { | ||
417 | final AlignmentGeometry alignment; | 471 | final AlignmentGeometry alignment; |
418 | 472 | ||
419 | @override | 473 | @override |
420 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 474 | + void layout(Context context, BoxConstraints constraints, |
475 | + {bool parentUsesSize = false}) { | ||
421 | PdfPoint size; | 476 | PdfPoint size; |
422 | if (child != null) { | 477 | if (child != null) { |
423 | child!.layout(context, const BoxConstraints(), parentUsesSize: true); | 478 | child!.layout(context, const BoxConstraints(), parentUsesSize: true); |
424 | assert(child!.box != null); | 479 | assert(child!.box != null); |
425 | - size = constraints.constrainSizeAndAttemptToPreserveAspectRatio(child!.box!.size); | 480 | + size = constraints |
481 | + .constrainSizeAndAttemptToPreserveAspectRatio(child!.box!.size); | ||
426 | } else { | 482 | } else { |
427 | size = constraints.smallest; | 483 | size = constraints.smallest; |
428 | } | 484 | } |
@@ -439,12 +495,15 @@ class FittedBox extends SingleChildWidget { | @@ -439,12 +495,15 @@ class FittedBox extends SingleChildWidget { | ||
439 | final sizes = applyBoxFit(fit, childSize, box!.size); | 495 | final sizes = applyBoxFit(fit, childSize, box!.size); |
440 | final scaleX = sizes.destination!.x / sizes.source!.x; | 496 | final scaleX = sizes.destination!.x / sizes.source!.x; |
441 | final scaleY = sizes.destination!.y / sizes.source!.y; | 497 | final scaleY = sizes.destination!.y / sizes.source!.y; |
442 | - final sourceRect = resolvedAlignment.inscribe(sizes.source!, PdfRect.fromPoints(PdfPoint.zero, childSize)); | ||
443 | - final destinationRect = resolvedAlignment.inscribe(sizes.destination!, box!); | 498 | + final sourceRect = resolvedAlignment.inscribe( |
499 | + sizes.source!, PdfRect.fromPoints(PdfPoint.zero, childSize)); | ||
500 | + final destinationRect = | ||
501 | + resolvedAlignment.inscribe(sizes.destination!, box!); | ||
444 | 502 | ||
445 | - final mat = Matrix4.translationValues(destinationRect.x, destinationRect.y, 0) | ||
446 | - ..scale(scaleX, scaleY, 1) | ||
447 | - ..translate(-sourceRect.x, -sourceRect.y); | 503 | + final mat = |
504 | + Matrix4.translationValues(destinationRect.x, destinationRect.y, 0) | ||
505 | + ..scale(scaleX, scaleY, 1) | ||
506 | + ..translate(-sourceRect.x, -sourceRect.y); | ||
448 | 507 | ||
449 | context.canvas | 508 | context.canvas |
450 | ..saveContext() | 509 | ..saveContext() |
@@ -502,10 +561,12 @@ class AspectRatio extends SingleChildWidget { | @@ -502,10 +561,12 @@ class AspectRatio extends SingleChildWidget { | ||
502 | } | 561 | } |
503 | 562 | ||
504 | @override | 563 | @override |
505 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 564 | + void layout(Context context, BoxConstraints constraints, |
565 | + {bool parentUsesSize = false}) { | ||
506 | box = PdfRect.fromPoints(PdfPoint.zero, _applyAspectRatio(constraints)); | 566 | box = PdfRect.fromPoints(PdfPoint.zero, _applyAspectRatio(constraints)); |
507 | if (child != null) { | 567 | if (child != null) { |
508 | - child!.layout(context, BoxConstraints.tightFor(width: box!.width, height: box!.height)); | 568 | + child!.layout(context, |
569 | + BoxConstraints.tightFor(width: box!.width, height: box!.height)); | ||
509 | } | 570 | } |
510 | assert(child!.box != null); | 571 | assert(child!.box != null); |
511 | } | 572 | } |
@@ -532,7 +593,8 @@ class CustomPaint extends SingleChildWidget { | @@ -532,7 +593,8 @@ class CustomPaint extends SingleChildWidget { | ||
532 | final PdfPoint size; | 593 | final PdfPoint size; |
533 | 594 | ||
534 | @override | 595 | @override |
535 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 596 | + void layout(Context context, BoxConstraints constraints, |
597 | + {bool parentUsesSize = false}) { | ||
536 | if (child != null) { | 598 | if (child != null) { |
537 | child!.layout(context, constraints, parentUsesSize: parentUsesSize); | 599 | child!.layout(context, constraints, parentUsesSize: parentUsesSize); |
538 | assert(child!.box != null); | 600 | assert(child!.box != null); |
@@ -599,7 +661,9 @@ class SizedBox extends StatelessWidget { | @@ -599,7 +661,9 @@ class SizedBox extends StatelessWidget { | ||
599 | 661 | ||
600 | @override | 662 | @override |
601 | Widget build(Context context) { | 663 | Widget build(Context context) { |
602 | - return ConstrainedBox(child: child, constraints: BoxConstraints.tightFor(width: width, height: height)); | 664 | + return ConstrainedBox( |
665 | + child: child, | ||
666 | + constraints: BoxConstraints.tightFor(width: width, height: height)); | ||
603 | } | 667 | } |
604 | } | 668 | } |
605 | 669 | ||
@@ -622,7 +686,8 @@ class Builder extends StatelessWidget { | @@ -622,7 +686,8 @@ class Builder extends StatelessWidget { | ||
622 | } | 686 | } |
623 | 687 | ||
624 | /// The signature of the [LayoutBuilder] builder function. | 688 | /// The signature of the [LayoutBuilder] builder function. |
625 | -typedef LayoutWidgetBuilder = Widget Function(Context context, BoxConstraints? constraints); | 689 | +typedef LayoutWidgetBuilder = Widget Function( |
690 | + Context context, BoxConstraints? constraints); | ||
626 | 691 | ||
627 | /// Builds a widget tree that can depend on the parent widget's size. | 692 | /// Builds a widget tree that can depend on the parent widget's size. |
628 | class LayoutBuilder extends StatelessWidget { | 693 | class LayoutBuilder extends StatelessWidget { |
@@ -637,7 +702,8 @@ class LayoutBuilder extends StatelessWidget { | @@ -637,7 +702,8 @@ class LayoutBuilder extends StatelessWidget { | ||
637 | BoxConstraints? _constraints; | 702 | BoxConstraints? _constraints; |
638 | 703 | ||
639 | @override | 704 | @override |
640 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 705 | + void layout(Context context, BoxConstraints constraints, |
706 | + {bool parentUsesSize = false}) { | ||
641 | _constraints = constraints; | 707 | _constraints = constraints; |
642 | super.layout(context, constraints); | 708 | super.layout(context, constraints); |
643 | } | 709 | } |
@@ -684,7 +750,8 @@ class FullPage extends SingleChildWidget { | @@ -684,7 +750,8 @@ class FullPage extends SingleChildWidget { | ||
684 | } | 750 | } |
685 | 751 | ||
686 | @override | 752 | @override |
687 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 753 | + void layout(Context context, BoxConstraints constraints, |
754 | + {bool parentUsesSize = false}) { | ||
688 | final constraints = _getConstraints(context); | 755 | final constraints = _getConstraints(context); |
689 | 756 | ||
690 | if (child != null) { | 757 | if (child != null) { |
@@ -904,11 +971,13 @@ class OverflowBox extends SingleChildWidget { | @@ -904,11 +971,13 @@ class OverflowBox extends SingleChildWidget { | ||
904 | } | 971 | } |
905 | 972 | ||
906 | @override | 973 | @override |
907 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 974 | + void layout(Context context, BoxConstraints constraints, |
975 | + {bool parentUsesSize = false}) { | ||
908 | box = PdfRect.fromPoints(PdfPoint.zero, constraints.smallest); | 976 | box = PdfRect.fromPoints(PdfPoint.zero, constraints.smallest); |
909 | 977 | ||
910 | if (child != null) { | 978 | if (child != null) { |
911 | - child!.layout(context, _getInnerConstraints(constraints), parentUsesSize: true); | 979 | + child!.layout(context, _getInnerConstraints(constraints), |
980 | + parentUsesSize: true); | ||
912 | assert(child!.box != null); | 981 | assert(child!.box != null); |
913 | final resolvedAlignment = alignment.resolve(Directionality.of(context)); | 982 | final resolvedAlignment = alignment.resolve(Directionality.of(context)); |
914 | child!.box = resolvedAlignment.inscribe(child!.box!.size, box!); | 983 | child!.box = resolvedAlignment.inscribe(child!.box!.size, box!); |
@@ -85,7 +85,9 @@ abstract class BorderRadiusGeometry { | @@ -85,7 +85,9 @@ abstract class BorderRadiusGeometry { | ||
85 | @override | 85 | @override |
86 | String toString() { | 86 | String toString() { |
87 | String? visual, logical; | 87 | String? visual, logical; |
88 | - if (_topLeft == _topRight && _topRight == _bottomLeft && _bottomLeft == _bottomRight) { | 88 | + if (_topLeft == _topRight && |
89 | + _topRight == _bottomLeft && | ||
90 | + _bottomLeft == _bottomRight) { | ||
89 | if (_topLeft != Radius.zero) { | 91 | if (_topLeft != Radius.zero) { |
90 | if (_topLeft.x == _topLeft.y) { | 92 | if (_topLeft.x == _topLeft.y) { |
91 | visual = 'BorderRadius.circular(${_topLeft.x.toStringAsFixed(1)})'; | 93 | visual = 'BorderRadius.circular(${_topLeft.x.toStringAsFixed(1)})'; |
@@ -125,10 +127,13 @@ abstract class BorderRadiusGeometry { | @@ -125,10 +127,13 @@ abstract class BorderRadiusGeometry { | ||
125 | result.write(')'); | 127 | result.write(')'); |
126 | visual = result.toString(); | 128 | visual = result.toString(); |
127 | } | 129 | } |
128 | - if (_topStart == _topEnd && _topEnd == _bottomEnd && _bottomEnd == _bottomStart) { | 130 | + if (_topStart == _topEnd && |
131 | + _topEnd == _bottomEnd && | ||
132 | + _bottomEnd == _bottomStart) { | ||
129 | if (_topStart != Radius.zero) { | 133 | if (_topStart != Radius.zero) { |
130 | if (_topStart.x == _topStart.y) { | 134 | if (_topStart.x == _topStart.y) { |
131 | - logical = 'BorderRadiusDirectional.circular(${_topStart.x.toStringAsFixed(1)})'; | 135 | + logical = |
136 | + 'BorderRadiusDirectional.circular(${_topStart.x.toStringAsFixed(1)})'; | ||
132 | } else { | 137 | } else { |
133 | logical = 'BorderRadiusDirectional.all($_topStart)'; | 138 | logical = 'BorderRadiusDirectional.all($_topStart)'; |
134 | } | 139 | } |
@@ -228,8 +233,6 @@ class BorderRadius extends BorderRadiusGeometry { | @@ -228,8 +233,6 @@ class BorderRadius extends BorderRadiusGeometry { | ||
228 | this.bottomRight = Radius.zero, | 233 | this.bottomRight = Radius.zero, |
229 | }); | 234 | }); |
230 | 235 | ||
231 | - | ||
232 | - | ||
233 | /// A border radius with all zero radii. | 236 | /// A border radius with all zero radii. |
234 | static const BorderRadius zero = BorderRadius.all(Radius.zero); | 237 | static const BorderRadius zero = BorderRadius.all(Radius.zero); |
235 | 238 | ||
@@ -245,14 +248,13 @@ class BorderRadius extends BorderRadiusGeometry { | @@ -245,14 +248,13 @@ class BorderRadius extends BorderRadiusGeometry { | ||
245 | /// The bottom-right [Radius]. | 248 | /// The bottom-right [Radius]. |
246 | final Radius bottomRight; | 249 | final Radius bottomRight; |
247 | 250 | ||
248 | - | ||
249 | @override | 251 | @override |
250 | - bool get isUniform => topLeft == topRight && topLeft == bottomLeft && topLeft == bottomRight; | 252 | + bool get isUniform => |
253 | + topLeft == topRight && topLeft == bottomLeft && topLeft == bottomRight; | ||
251 | 254 | ||
252 | @override | 255 | @override |
253 | Radius get uniform => isUniform ? topLeft : Radius.zero; | 256 | Radius get uniform => isUniform ? topLeft : Radius.zero; |
254 | 257 | ||
255 | - | ||
256 | void paint(Context context, PdfRect box) { | 258 | void paint(Context context, PdfRect box) { |
257 | // Ellipse 4-spline magic number | 259 | // Ellipse 4-spline magic number |
258 | const _m4 = 0.551784; | 260 | const _m4 = 0.551784; |
@@ -261,13 +263,23 @@ class BorderRadius extends BorderRadiusGeometry { | @@ -261,13 +263,23 @@ class BorderRadius extends BorderRadiusGeometry { | ||
261 | // Start | 263 | // Start |
262 | ..moveTo(box.x, box.y + bottomLeft.y) | 264 | ..moveTo(box.x, box.y + bottomLeft.y) |
263 | // bottomLeft | 265 | // bottomLeft |
264 | - ..curveTo(box.x, box.y - _m4 * bottomLeft.y + bottomLeft.y, box.x - _m4 * bottomLeft.x + bottomLeft.x, box.y, | ||
265 | - box.x + bottomLeft.x, box.y) | 266 | + ..curveTo( |
267 | + box.x, | ||
268 | + box.y - _m4 * bottomLeft.y + bottomLeft.y, | ||
269 | + box.x - _m4 * bottomLeft.x + bottomLeft.x, | ||
270 | + box.y, | ||
271 | + box.x + bottomLeft.x, | ||
272 | + box.y) | ||
266 | // bottom | 273 | // bottom |
267 | ..lineTo(box.x + box.width - bottomRight.x, box.y) | 274 | ..lineTo(box.x + box.width - bottomRight.x, box.y) |
268 | // bottomRight | 275 | // bottomRight |
269 | - ..curveTo(box.x + _m4 * bottomRight.x + box.width - bottomRight.x, box.y, box.x + box.width, | ||
270 | - box.y - _m4 * bottomRight.y + bottomRight.y, box.x + box.width, box.y + bottomRight.y) | 276 | + ..curveTo( |
277 | + box.x + _m4 * bottomRight.x + box.width - bottomRight.x, | ||
278 | + box.y, | ||
279 | + box.x + box.width, | ||
280 | + box.y - _m4 * bottomRight.y + bottomRight.y, | ||
281 | + box.x + box.width, | ||
282 | + box.y + bottomRight.y) | ||
271 | // right | 283 | // right |
272 | ..lineTo(box.x + box.width, box.y + box.height - topRight.y) | 284 | ..lineTo(box.x + box.width, box.y + box.height - topRight.y) |
273 | // topRight | 285 | // topRight |
@@ -281,8 +293,13 @@ class BorderRadius extends BorderRadiusGeometry { | @@ -281,8 +293,13 @@ class BorderRadius extends BorderRadiusGeometry { | ||
281 | // top | 293 | // top |
282 | ..lineTo(box.x + topLeft.x, box.y + box.height) | 294 | ..lineTo(box.x + topLeft.x, box.y + box.height) |
283 | // topLeft | 295 | // topLeft |
284 | - ..curveTo(box.x - _m4 * topLeft.x + topLeft.x, box.y + box.height, box.x, | ||
285 | - box.y + _m4 * topLeft.y + box.height - topLeft.y, box.x, box.y + box.height - topLeft.y) | 296 | + ..curveTo( |
297 | + box.x - _m4 * topLeft.x + topLeft.x, | ||
298 | + box.y + box.height, | ||
299 | + box.x, | ||
300 | + box.y + _m4 * topLeft.y + box.height - topLeft.y, | ||
301 | + box.x, | ||
302 | + box.y + box.height - topLeft.y) | ||
286 | // left | 303 | // left |
287 | ..lineTo(box.x, box.y + bottomLeft.y); | 304 | ..lineTo(box.x, box.y + bottomLeft.y); |
288 | } | 305 | } |
@@ -329,17 +346,19 @@ class BorderRadius extends BorderRadiusGeometry { | @@ -329,17 +346,19 @@ class BorderRadius extends BorderRadiusGeometry { | ||
329 | /// `topRight` instead of `topStart` and `topEnd`). | 346 | /// `topRight` instead of `topStart` and `topEnd`). |
330 | class BorderRadiusDirectional extends BorderRadiusGeometry { | 347 | class BorderRadiusDirectional extends BorderRadiusGeometry { |
331 | /// Creates a border radius where all radii are [radius]. | 348 | /// Creates a border radius where all radii are [radius]. |
332 | - const BorderRadiusDirectional.all(Radius radius) : this.only( | ||
333 | - topStart: radius, | ||
334 | - topEnd: radius, | ||
335 | - bottomStart: radius, | ||
336 | - bottomEnd: radius, | ||
337 | - ); | 349 | + const BorderRadiusDirectional.all(Radius radius) |
350 | + : this.only( | ||
351 | + topStart: radius, | ||
352 | + topEnd: radius, | ||
353 | + bottomStart: radius, | ||
354 | + bottomEnd: radius, | ||
355 | + ); | ||
338 | 356 | ||
339 | /// Creates a border radius where all radii are [Radius.circular(radius)]. | 357 | /// Creates a border radius where all radii are [Radius.circular(radius)]. |
340 | - BorderRadiusDirectional.circular(double radius) : this.all( | ||
341 | - Radius.circular(radius), | ||
342 | - ); | 358 | + BorderRadiusDirectional.circular(double radius) |
359 | + : this.all( | ||
360 | + Radius.circular(radius), | ||
361 | + ); | ||
343 | 362 | ||
344 | /// Creates a vertically symmetric border radius where the top and bottom | 363 | /// Creates a vertically symmetric border radius where the top and bottom |
345 | /// sides of the rectangle have the same radii. | 364 | /// sides of the rectangle have the same radii. |
@@ -347,11 +366,11 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { | @@ -347,11 +366,11 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { | ||
347 | Radius top = Radius.zero, | 366 | Radius top = Radius.zero, |
348 | Radius bottom = Radius.zero, | 367 | Radius bottom = Radius.zero, |
349 | }) : this.only( | 368 | }) : this.only( |
350 | - topStart: top, | ||
351 | - topEnd: top, | ||
352 | - bottomStart: bottom, | ||
353 | - bottomEnd: bottom, | ||
354 | - ); | 369 | + topStart: top, |
370 | + topEnd: top, | ||
371 | + bottomStart: bottom, | ||
372 | + bottomEnd: bottom, | ||
373 | + ); | ||
355 | 374 | ||
356 | /// Creates a horizontally symmetrical border radius where the start and end | 375 | /// Creates a horizontally symmetrical border radius where the start and end |
357 | /// sides of the rectangle have the same radii. | 376 | /// sides of the rectangle have the same radii. |
@@ -359,11 +378,11 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { | @@ -359,11 +378,11 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { | ||
359 | Radius start = Radius.zero, | 378 | Radius start = Radius.zero, |
360 | Radius end = Radius.zero, | 379 | Radius end = Radius.zero, |
361 | }) : this.only( | 380 | }) : this.only( |
362 | - topStart: start, | ||
363 | - topEnd: end, | ||
364 | - bottomStart: start, | ||
365 | - bottomEnd: end, | ||
366 | - ); | 381 | + topStart: start, |
382 | + topEnd: end, | ||
383 | + bottomStart: start, | ||
384 | + bottomEnd: end, | ||
385 | + ); | ||
367 | 386 | ||
368 | /// Creates a border radius with only the given non-zero values. The other | 387 | /// Creates a border radius with only the given non-zero values. The other |
369 | /// corners will be right angles. | 388 | /// corners will be right angles. |
@@ -378,7 +397,8 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { | @@ -378,7 +397,8 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { | ||
378 | /// | 397 | /// |
379 | /// Consider using [BorderRadius.zero] instead, since that object has the same | 398 | /// Consider using [BorderRadius.zero] instead, since that object has the same |
380 | /// effect, but will be cheaper to [resolve]. | 399 | /// effect, but will be cheaper to [resolve]. |
381 | - static const BorderRadiusDirectional zero = BorderRadiusDirectional.all(Radius.zero); | 400 | + static const BorderRadiusDirectional zero = |
401 | + BorderRadiusDirectional.all(Radius.zero); | ||
382 | 402 | ||
383 | /// The top-start [Radius]. | 403 | /// The top-start [Radius]. |
384 | final Radius topStart; | 404 | final Radius topStart; |
@@ -417,7 +437,8 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { | @@ -417,7 +437,8 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { | ||
417 | Radius get _bottomRight => Radius.zero; | 437 | Radius get _bottomRight => Radius.zero; |
418 | 438 | ||
419 | @override | 439 | @override |
420 | - bool get isUniform => topStart == topEnd && topStart == bottomStart && topStart == bottomEnd; | 440 | + bool get isUniform => |
441 | + topStart == topEnd && topStart == bottomStart && topStart == bottomEnd; | ||
421 | 442 | ||
422 | @override | 443 | @override |
423 | Radius get uniform => isUniform ? topStart : Radius.zero; | 444 | Radius get uniform => isUniform ? topStart : Radius.zero; |
@@ -442,4 +463,4 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { | @@ -442,4 +463,4 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { | ||
442 | ); | 463 | ); |
443 | } | 464 | } |
444 | } | 465 | } |
445 | -} | ||
466 | +} |
@@ -207,7 +207,7 @@ class RadialGradient extends Gradient { | @@ -207,7 +207,7 @@ class RadialGradient extends Gradient { | ||
207 | final _focal = focal ?? center; | 207 | final _focal = focal ?? center; |
208 | 208 | ||
209 | final _radius = math.min(box.width, box.height); | 209 | final _radius = math.min(box.width, box.height); |
210 | - final textDirection = Directionality.of(context); | 210 | + final textDirection = Directionality.of(context); |
211 | context.canvas | 211 | context.canvas |
212 | ..saveContext() | 212 | ..saveContext() |
213 | ..clipPath() | 213 | ..clipPath() |
@@ -277,7 +277,8 @@ class BoxDecoration { | @@ -277,7 +277,8 @@ class BoxDecoration { | ||
277 | PdfRect box, [ | 277 | PdfRect box, [ |
278 | PaintPhase phase = PaintPhase.all, | 278 | PaintPhase phase = PaintPhase.all, |
279 | ]) { | 279 | ]) { |
280 | - final resolvedBorderRadius = borderRadius?.resolve(Directionality.of(context)); | 280 | + final resolvedBorderRadius = |
281 | + borderRadius?.resolve(Directionality.of(context)); | ||
281 | if (phase == PaintPhase.all || phase == PaintPhase.background) { | 282 | if (phase == PaintPhase.all || phase == PaintPhase.background) { |
282 | if (color != null) { | 283 | if (color != null) { |
283 | switch (shape) { | 284 | switch (shape) { |
@@ -363,7 +364,7 @@ class BoxDecoration { | @@ -363,7 +364,7 @@ class BoxDecoration { | ||
363 | 364 | ||
364 | break; | 365 | break; |
365 | case BoxShape.rectangle: | 366 | case BoxShape.rectangle: |
366 | - if (resolvedBorderRadius!= null) { | 367 | + if (resolvedBorderRadius != null) { |
367 | resolvedBorderRadius.paint(context, box); | 368 | resolvedBorderRadius.paint(context, box); |
368 | context.canvas.clipPath(); | 369 | context.canvas.clipPath(); |
369 | } | 370 | } |
@@ -394,8 +394,9 @@ class Flex extends MultiChildWidget with SpanningWidget { | @@ -394,8 +394,9 @@ class Flex extends MultiChildWidget with SpanningWidget { | ||
394 | double? leadingSpace; | 394 | double? leadingSpace; |
395 | late double betweenSpace; | 395 | late double betweenSpace; |
396 | 396 | ||
397 | - final textDirection = Directionality.of(context) ; | ||
398 | - final flipMainAxis = !(_startIsTopLeft(direction, textDirection, verticalDirection) ?? true); | 397 | + final textDirection = Directionality.of(context); |
398 | + final flipMainAxis = | ||
399 | + !(_startIsTopLeft(direction, textDirection, verticalDirection) ?? true); | ||
399 | 400 | ||
400 | switch (mainAxisAlignment) { | 401 | switch (mainAxisAlignment) { |
401 | case MainAxisAlignment.start: | 402 | case MainAxisAlignment.start: |
@@ -436,8 +437,9 @@ class Flex extends MultiChildWidget with SpanningWidget { | @@ -436,8 +437,9 @@ class Flex extends MultiChildWidget with SpanningWidget { | ||
436 | switch (crossAxisAlignment) { | 437 | switch (crossAxisAlignment) { |
437 | case CrossAxisAlignment.start: | 438 | case CrossAxisAlignment.start: |
438 | case CrossAxisAlignment.end: | 439 | case CrossAxisAlignment.end: |
439 | - childCrossPosition = _startIsTopLeft(flipAxis(direction), textDirection, verticalDirection) | ||
440 | - == (crossAxisAlignment == CrossAxisAlignment.start) | 440 | + childCrossPosition = _startIsTopLeft( |
441 | + flipAxis(direction), textDirection, verticalDirection) == | ||
442 | + (crossAxisAlignment == CrossAxisAlignment.start) | ||
441 | ? 0.0 | 443 | ? 0.0 |
442 | : crossSize - _getCrossSize(child); | 444 | : crossSize - _getCrossSize(child); |
443 | break; | 445 | break; |
@@ -479,7 +481,8 @@ class Flex extends MultiChildWidget with SpanningWidget { | @@ -479,7 +481,8 @@ class Flex extends MultiChildWidget with SpanningWidget { | ||
479 | } | 481 | } |
480 | } | 482 | } |
481 | 483 | ||
482 | - bool? _startIsTopLeft(Axis direction, TextDirection? textDirection, VerticalDirection? verticalDirection) { | 484 | + bool? _startIsTopLeft(Axis direction, TextDirection? textDirection, |
485 | + VerticalDirection? verticalDirection) { | ||
483 | // If the relevant value of textDirection or verticalDirection is null, this returns null too. | 486 | // If the relevant value of textDirection or verticalDirection is null, this returns null too. |
484 | switch (direction) { | 487 | switch (direction) { |
485 | case Axis.horizontal: | 488 | case Axis.horizontal: |
@@ -26,7 +26,10 @@ import '../../widgets.dart'; | @@ -26,7 +26,10 @@ import '../../widgets.dart'; | ||
26 | class BoxConstraints { | 26 | class BoxConstraints { |
27 | /// Creates box constraints with the given constraints. | 27 | /// Creates box constraints with the given constraints. |
28 | const BoxConstraints( | 28 | const BoxConstraints( |
29 | - {this.minWidth = 0.0, this.maxWidth = double.infinity, this.minHeight = 0.0, this.maxHeight = double.infinity}); | 29 | + {this.minWidth = 0.0, |
30 | + this.maxWidth = double.infinity, | ||
31 | + this.minHeight = 0.0, | ||
32 | + this.maxHeight = double.infinity}); | ||
30 | 33 | ||
31 | /// Creates box constraints that require the given width or height. | 34 | /// Creates box constraints that require the given width or height. |
32 | const BoxConstraints.tightFor({double? width, double? height}) | 35 | const BoxConstraints.tightFor({double? width, double? height}) |
@@ -101,7 +104,8 @@ class BoxConstraints { | @@ -101,7 +104,8 @@ class BoxConstraints { | ||
101 | return result; | 104 | return result; |
102 | } | 105 | } |
103 | 106 | ||
104 | - PdfRect constrainRect({double width = double.infinity, double height = double.infinity}) { | 107 | + PdfRect constrainRect( |
108 | + {double width = double.infinity, double height = double.infinity}) { | ||
105 | final result = PdfPoint(constrainWidth(width), constrainHeight(height)); | 109 | final result = PdfPoint(constrainWidth(width), constrainHeight(height)); |
106 | return PdfRect.fromPoints(PdfPoint.zero, result); | 110 | return PdfRect.fromPoints(PdfPoint.zero, result); |
107 | } | 111 | } |
@@ -158,8 +162,10 @@ class BoxConstraints { | @@ -158,8 +162,10 @@ class BoxConstraints { | ||
158 | return BoxConstraints( | 162 | return BoxConstraints( |
159 | minWidth: width == null ? minWidth : width.clamp(minWidth, maxWidth), | 163 | minWidth: width == null ? minWidth : width.clamp(minWidth, maxWidth), |
160 | maxWidth: width == null ? maxWidth : width.clamp(minWidth, maxWidth), | 164 | maxWidth: width == null ? maxWidth : width.clamp(minWidth, maxWidth), |
161 | - minHeight: height == null ? minHeight : height.clamp(minHeight, maxHeight), | ||
162 | - maxHeight: height == null ? maxHeight : height.clamp(minHeight, maxHeight)); | 165 | + minHeight: |
166 | + height == null ? minHeight : height.clamp(minHeight, maxHeight), | ||
167 | + maxHeight: | ||
168 | + height == null ? maxHeight : height.clamp(minHeight, maxHeight)); | ||
163 | } | 169 | } |
164 | 170 | ||
165 | /// Returns new box constraints that are smaller by the given edge dimensions. | 171 | /// Returns new box constraints that are smaller by the given edge dimensions. |
@@ -191,11 +197,17 @@ class BoxConstraints { | @@ -191,11 +197,17 @@ class BoxConstraints { | ||
191 | return BoxConstraints( | 197 | return BoxConstraints( |
192 | minWidth: minWidth.clamp(constraints.minWidth, constraints.maxWidth), | 198 | minWidth: minWidth.clamp(constraints.minWidth, constraints.maxWidth), |
193 | maxWidth: maxWidth.clamp(constraints.minWidth, constraints.maxWidth), | 199 | maxWidth: maxWidth.clamp(constraints.minWidth, constraints.maxWidth), |
194 | - minHeight: minHeight.clamp(constraints.minHeight, constraints.maxHeight), | ||
195 | - maxHeight: maxHeight.clamp(constraints.minHeight, constraints.maxHeight)); | 200 | + minHeight: |
201 | + minHeight.clamp(constraints.minHeight, constraints.maxHeight), | ||
202 | + maxHeight: | ||
203 | + maxHeight.clamp(constraints.minHeight, constraints.maxHeight)); | ||
196 | } | 204 | } |
197 | 205 | ||
198 | - BoxConstraints copyWith({double? minWidth, double? maxWidth, double? minHeight, double? maxHeight}) { | 206 | + BoxConstraints copyWith( |
207 | + {double? minWidth, | ||
208 | + double? maxWidth, | ||
209 | + double? minHeight, | ||
210 | + double? maxHeight}) { | ||
199 | return BoxConstraints( | 211 | return BoxConstraints( |
200 | minWidth: minWidth ?? this.minWidth, | 212 | minWidth: minWidth ?? this.minWidth, |
201 | maxWidth: maxWidth ?? this.maxWidth, | 213 | maxWidth: maxWidth ?? this.maxWidth, |
@@ -308,7 +320,8 @@ class EdgeInsets extends EdgeInsetsGeometry { | @@ -308,7 +320,8 @@ class EdgeInsets extends EdgeInsetsGeometry { | ||
308 | right = value, | 320 | right = value, |
309 | bottom = value; | 321 | bottom = value; |
310 | 322 | ||
311 | - const EdgeInsets.only({this.left = 0.0, this.top = 0.0, this.right = 0.0, this.bottom = 0.0}); | 323 | + const EdgeInsets.only( |
324 | + {this.left = 0.0, this.top = 0.0, this.right = 0.0, this.bottom = 0.0}); | ||
312 | 325 | ||
313 | const EdgeInsets.symmetric({double vertical = 0.0, double horizontal = 0.0}) | 326 | const EdgeInsets.symmetric({double vertical = 0.0, double horizontal = 0.0}) |
314 | : left = horizontal, | 327 | : left = horizontal, |
@@ -385,7 +398,8 @@ class EdgeInsets extends EdgeInsetsGeometry { | @@ -385,7 +398,8 @@ class EdgeInsets extends EdgeInsetsGeometry { | ||
385 | } | 398 | } |
386 | 399 | ||
387 | class _MixedEdgeInsets extends EdgeInsetsGeometry { | 400 | class _MixedEdgeInsets extends EdgeInsetsGeometry { |
388 | - const _MixedEdgeInsets.fromLRSETB(this._left, this._right, this._start, this._end, this._top, this._bottom); | 401 | + const _MixedEdgeInsets.fromLRSETB( |
402 | + this._left, this._right, this._start, this._end, this._top, this._bottom); | ||
389 | 403 | ||
390 | @override | 404 | @override |
391 | final double _left; | 405 | final double _left; |
@@ -410,9 +424,11 @@ class _MixedEdgeInsets extends EdgeInsetsGeometry { | @@ -410,9 +424,11 @@ class _MixedEdgeInsets extends EdgeInsetsGeometry { | ||
410 | assert(direction != null); | 424 | assert(direction != null); |
411 | switch (direction!) { | 425 | switch (direction!) { |
412 | case TextDirection.rtl: | 426 | case TextDirection.rtl: |
413 | - return EdgeInsets.fromLTRB(_end + _left, _top, _start + _right, _bottom); | 427 | + return EdgeInsets.fromLTRB( |
428 | + _end + _left, _top, _start + _right, _bottom); | ||
414 | case TextDirection.ltr: | 429 | case TextDirection.ltr: |
415 | - return EdgeInsets.fromLTRB(_start + _left, _top, _end + _right, _bottom); | 430 | + return EdgeInsets.fromLTRB( |
431 | + _start + _left, _top, _end + _right, _bottom); | ||
416 | } | 432 | } |
417 | } | 433 | } |
418 | } | 434 | } |
@@ -430,7 +446,8 @@ class _MixedEdgeInsets extends EdgeInsetsGeometry { | @@ -430,7 +446,8 @@ class _MixedEdgeInsets extends EdgeInsetsGeometry { | ||
430 | /// of start and end). | 446 | /// of start and end). |
431 | class EdgeInsetsDirectional extends EdgeInsetsGeometry { | 447 | class EdgeInsetsDirectional extends EdgeInsetsGeometry { |
432 | /// Creates insets from offsets from the start, top, end, and bottom. | 448 | /// Creates insets from offsets from the start, top, end, and bottom. |
433 | - const EdgeInsetsDirectional.fromSTEB(this.start, this.top, this.end, this.bottom); | 449 | + const EdgeInsetsDirectional.fromSTEB( |
450 | + this.start, this.top, this.end, this.bottom); | ||
434 | 451 | ||
435 | /// Creates insets with only the given values non-zero. | 452 | /// Creates insets with only the given values non-zero. |
436 | /// | 453 | /// |
@@ -580,7 +597,6 @@ abstract class AlignmentGeometry { | @@ -580,7 +597,6 @@ abstract class AlignmentGeometry { | ||
580 | /// const constructors so that they can be used in const expressions. | 597 | /// const constructors so that they can be used in const expressions. |
581 | const AlignmentGeometry(); | 598 | const AlignmentGeometry(); |
582 | 599 | ||
583 | - | ||
584 | /// Convert this instance into an [Alignment], which uses literal | 600 | /// Convert this instance into an [Alignment], which uses literal |
585 | /// coordinates (the `x` coordinate being explicitly a distance from the | 601 | /// coordinates (the `x` coordinate being explicitly a distance from the |
586 | /// left). | 602 | /// left). |
@@ -591,7 +607,6 @@ abstract class AlignmentGeometry { | @@ -591,7 +607,6 @@ abstract class AlignmentGeometry { | ||
591 | /// * [AlignmentDirectional], which flips the horizontal direction | 607 | /// * [AlignmentDirectional], which flips the horizontal direction |
592 | /// based on the `direction` argument. | 608 | /// based on the `direction` argument. |
593 | Alignment resolve(TextDirection? direction); | 609 | Alignment resolve(TextDirection? direction); |
594 | - | ||
595 | } | 610 | } |
596 | 611 | ||
597 | class Alignment extends AlignmentGeometry { | 612 | class Alignment extends AlignmentGeometry { |
@@ -753,7 +768,8 @@ class AlignmentDirectional extends AlignmentGeometry { | @@ -753,7 +768,8 @@ class AlignmentDirectional extends AlignmentGeometry { | ||
753 | static const AlignmentDirectional topEnd = AlignmentDirectional(1.0, -1.0); | 768 | static const AlignmentDirectional topEnd = AlignmentDirectional(1.0, -1.0); |
754 | 769 | ||
755 | /// The center point along the "start" edge. | 770 | /// The center point along the "start" edge. |
756 | - static const AlignmentDirectional centerStart = AlignmentDirectional(-1.0, 0.0); | 771 | + static const AlignmentDirectional centerStart = |
772 | + AlignmentDirectional(-1.0, 0.0); | ||
757 | 773 | ||
758 | /// The center point, both horizontally and vertically. | 774 | /// The center point, both horizontally and vertically. |
759 | /// | 775 | /// |
@@ -765,13 +781,15 @@ class AlignmentDirectional extends AlignmentGeometry { | @@ -765,13 +781,15 @@ class AlignmentDirectional extends AlignmentGeometry { | ||
765 | static const AlignmentDirectional centerEnd = AlignmentDirectional(1.0, 0.0); | 781 | static const AlignmentDirectional centerEnd = AlignmentDirectional(1.0, 0.0); |
766 | 782 | ||
767 | /// The bottom corner on the "start" side. | 783 | /// The bottom corner on the "start" side. |
768 | - static const AlignmentDirectional bottomStart = AlignmentDirectional(-1.0, 1.0); | 784 | + static const AlignmentDirectional bottomStart = |
785 | + AlignmentDirectional(-1.0, 1.0); | ||
769 | 786 | ||
770 | /// The center point along the bottom edge. | 787 | /// The center point along the bottom edge. |
771 | /// | 788 | /// |
772 | /// Consider using [Alignment.bottomCenter] instead, as it does not | 789 | /// Consider using [Alignment.bottomCenter] instead, as it does not |
773 | /// need to be [resolve]d to be used. | 790 | /// need to be [resolve]d to be used. |
774 | - static const AlignmentDirectional bottomCenter = AlignmentDirectional(0.0, 1.0); | 791 | + static const AlignmentDirectional bottomCenter = |
792 | + AlignmentDirectional(0.0, 1.0); | ||
775 | 793 | ||
776 | /// The bottom corner on the "end" side. | 794 | /// The bottom corner on the "end" side. |
777 | static const AlignmentDirectional bottomEnd = AlignmentDirectional(1.0, 1.0); | 795 | static const AlignmentDirectional bottomEnd = AlignmentDirectional(1.0, 1.0); |
@@ -813,7 +831,8 @@ class AlignmentDirectional extends AlignmentGeometry { | @@ -813,7 +831,8 @@ class AlignmentDirectional extends AlignmentGeometry { | ||
813 | 831 | ||
814 | @override | 832 | @override |
815 | Alignment resolve(TextDirection? direction) { | 833 | Alignment resolve(TextDirection? direction) { |
816 | - assert(direction != null, 'Cannot resolve $runtimeType without a TextDirection.'); | 834 | + assert(direction != null, |
835 | + 'Cannot resolve $runtimeType without a TextDirection.'); | ||
817 | switch (direction!) { | 836 | switch (direction!) { |
818 | case TextDirection.rtl: | 837 | case TextDirection.rtl: |
819 | return Alignment(-start, y); | 838 | return Alignment(-start, y); |
@@ -823,7 +842,6 @@ class AlignmentDirectional extends AlignmentGeometry { | @@ -823,7 +842,6 @@ class AlignmentDirectional extends AlignmentGeometry { | ||
823 | } | 842 | } |
824 | } | 843 | } |
825 | 844 | ||
826 | - | ||
827 | /// An offset that's expressed as a fraction of a [PdfPoint]. | 845 | /// An offset that's expressed as a fraction of a [PdfPoint]. |
828 | @immutable | 846 | @immutable |
829 | class FractionalOffset extends Alignment { | 847 | class FractionalOffset extends Alignment { |
@@ -844,7 +862,10 @@ class FittedSizes { | @@ -844,7 +862,10 @@ class FittedSizes { | ||
844 | } | 862 | } |
845 | 863 | ||
846 | FittedSizes applyBoxFit(BoxFit fit, PdfPoint inputSize, PdfPoint outputSize) { | 864 | FittedSizes applyBoxFit(BoxFit fit, PdfPoint inputSize, PdfPoint outputSize) { |
847 | - if (inputSize.y <= 0.0 || inputSize.x <= 0.0 || outputSize.y <= 0.0 || outputSize.x <= 0.0) { | 865 | + if (inputSize.y <= 0.0 || |
866 | + inputSize.x <= 0.0 || | ||
867 | + outputSize.y <= 0.0 || | ||
868 | + outputSize.x <= 0.0) { | ||
848 | return const FittedSizes(PdfPoint.zero, PdfPoint.zero); | 869 | return const FittedSizes(PdfPoint.zero, PdfPoint.zero); |
849 | } | 870 | } |
850 | 871 | ||
@@ -857,29 +878,38 @@ FittedSizes applyBoxFit(BoxFit fit, PdfPoint inputSize, PdfPoint outputSize) { | @@ -857,29 +878,38 @@ FittedSizes applyBoxFit(BoxFit fit, PdfPoint inputSize, PdfPoint outputSize) { | ||
857 | case BoxFit.contain: | 878 | case BoxFit.contain: |
858 | sourceSize = inputSize; | 879 | sourceSize = inputSize; |
859 | if (outputSize.x / outputSize.y > sourceSize.x / sourceSize.y) { | 880 | if (outputSize.x / outputSize.y > sourceSize.x / sourceSize.y) { |
860 | - destinationSize = PdfPoint(sourceSize.x * outputSize.y / sourceSize.y, outputSize.y); | 881 | + destinationSize = |
882 | + PdfPoint(sourceSize.x * outputSize.y / sourceSize.y, outputSize.y); | ||
861 | } else { | 883 | } else { |
862 | - destinationSize = PdfPoint(outputSize.x, sourceSize.y * outputSize.x / sourceSize.x); | 884 | + destinationSize = |
885 | + PdfPoint(outputSize.x, sourceSize.y * outputSize.x / sourceSize.x); | ||
863 | } | 886 | } |
864 | break; | 887 | break; |
865 | case BoxFit.cover: | 888 | case BoxFit.cover: |
866 | if (outputSize.x / outputSize.y > inputSize.x / inputSize.y) { | 889 | if (outputSize.x / outputSize.y > inputSize.x / inputSize.y) { |
867 | - sourceSize = PdfPoint(inputSize.x, inputSize.x * outputSize.y / outputSize.x); | 890 | + sourceSize = |
891 | + PdfPoint(inputSize.x, inputSize.x * outputSize.y / outputSize.x); | ||
868 | } else { | 892 | } else { |
869 | - sourceSize = PdfPoint(inputSize.y * outputSize.x / outputSize.y, inputSize.y); | 893 | + sourceSize = |
894 | + PdfPoint(inputSize.y * outputSize.x / outputSize.y, inputSize.y); | ||
870 | } | 895 | } |
871 | destinationSize = outputSize; | 896 | destinationSize = outputSize; |
872 | break; | 897 | break; |
873 | case BoxFit.fitWidth: | 898 | case BoxFit.fitWidth: |
874 | - sourceSize = PdfPoint(inputSize.x, inputSize.x * outputSize.y / outputSize.x); | ||
875 | - destinationSize = PdfPoint(outputSize.x, sourceSize.y * outputSize.x / sourceSize.x); | 899 | + sourceSize = |
900 | + PdfPoint(inputSize.x, inputSize.x * outputSize.y / outputSize.x); | ||
901 | + destinationSize = | ||
902 | + PdfPoint(outputSize.x, sourceSize.y * outputSize.x / sourceSize.x); | ||
876 | break; | 903 | break; |
877 | case BoxFit.fitHeight: | 904 | case BoxFit.fitHeight: |
878 | - sourceSize = PdfPoint(inputSize.y * outputSize.x / outputSize.y, inputSize.y); | ||
879 | - destinationSize = PdfPoint(sourceSize.x * outputSize.y / sourceSize.y, outputSize.y); | 905 | + sourceSize = |
906 | + PdfPoint(inputSize.y * outputSize.x / outputSize.y, inputSize.y); | ||
907 | + destinationSize = | ||
908 | + PdfPoint(sourceSize.x * outputSize.y / sourceSize.y, outputSize.y); | ||
880 | break; | 909 | break; |
881 | case BoxFit.none: | 910 | case BoxFit.none: |
882 | - sourceSize = PdfPoint(math.min(inputSize.x, outputSize.x), math.min(inputSize.y, outputSize.y)); | 911 | + sourceSize = PdfPoint(math.min(inputSize.x, outputSize.x), |
912 | + math.min(inputSize.y, outputSize.y)); | ||
883 | destinationSize = sourceSize; | 913 | destinationSize = sourceSize; |
884 | break; | 914 | break; |
885 | case BoxFit.scaleDown: | 915 | case BoxFit.scaleDown: |
@@ -200,7 +200,6 @@ class GridPaper extends SingleChildWidget { | @@ -200,7 +200,6 @@ class GridPaper extends SingleChildWidget { | ||
200 | @override | 200 | @override |
201 | void layout(Context context, BoxConstraints constraints, | 201 | void layout(Context context, BoxConstraints constraints, |
202 | {bool parentUsesSize = false}) { | 202 | {bool parentUsesSize = false}) { |
203 | - | ||
204 | final resolvedMargin = margin.resolve(Directionality.of(context)); | 203 | final resolvedMargin = margin.resolve(Directionality.of(context)); |
205 | box = PdfRect.fromPoints(PdfPoint.zero, constraints.biggest); | 204 | box = PdfRect.fromPoints(PdfPoint.zero, constraints.biggest); |
206 | if (child != null) { | 205 | if (child != null) { |
@@ -216,7 +215,8 @@ class GridPaper extends SingleChildWidget { | @@ -216,7 +215,8 @@ class GridPaper extends SingleChildWidget { | ||
216 | 215 | ||
217 | assert(child!.box != null); | 216 | assert(child!.box != null); |
218 | child!.box = PdfRect.fromPoints( | 217 | child!.box = PdfRect.fromPoints( |
219 | - PdfPoint(resolvedMargin.left, box!.top - resolvedMargin.top - child!.box!.height), | 218 | + PdfPoint(resolvedMargin.left, |
219 | + box!.top - resolvedMargin.top - child!.box!.height), | ||
220 | child!.box!.size); | 220 | child!.box!.size); |
221 | } | 221 | } |
222 | } | 222 | } |
@@ -273,8 +273,8 @@ class GridPaper extends SingleChildWidget { | @@ -273,8 +273,8 @@ class GridPaper extends SingleChildWidget { | ||
273 | context.canvas | 273 | context.canvas |
274 | ..setStrokeColor(border.left.color) | 274 | ..setStrokeColor(border.left.color) |
275 | ..setLineWidth(border.left.width) | 275 | ..setLineWidth(border.left.width) |
276 | - ..drawLine(box!.left + resolvedMargin.left, box!.top, box!.left + resolvedMargin.left, | ||
277 | - box!.bottom) | 276 | + ..drawLine(box!.left + resolvedMargin.left, box!.top, |
277 | + box!.left + resolvedMargin.left, box!.bottom) | ||
278 | ..strokePath(); | 278 | ..strokePath(); |
279 | border.left.style.unsetStyle(context); | 279 | border.left.style.unsetStyle(context); |
280 | } | 280 | } |
@@ -293,8 +293,8 @@ class GridPaper extends SingleChildWidget { | @@ -293,8 +293,8 @@ class GridPaper extends SingleChildWidget { | ||
293 | context.canvas | 293 | context.canvas |
294 | ..setStrokeColor(border.top.color) | 294 | ..setStrokeColor(border.top.color) |
295 | ..setLineWidth(border.top.width) | 295 | ..setLineWidth(border.top.width) |
296 | - ..drawLine( | ||
297 | - box!.left, box!.top - resolvedMargin.top, box!.right, box!.top - resolvedMargin.top) | 296 | + ..drawLine(box!.left, box!.top - resolvedMargin.top, box!.right, |
297 | + box!.top - resolvedMargin.top) | ||
298 | ..strokePath(); | 298 | ..strokePath(); |
299 | border.top.style.unsetStyle(context); | 299 | border.top.style.unsetStyle(context); |
300 | } | 300 | } |
@@ -47,7 +47,8 @@ class GridViewContext extends WidgetContext { | @@ -47,7 +47,8 @@ class GridViewContext extends WidgetContext { | ||
47 | } | 47 | } |
48 | 48 | ||
49 | @override | 49 | @override |
50 | - String toString() => '$runtimeType first:$firstChild last:$lastChild size:${childCrossAxis}x$childMainAxis'; | 50 | + String toString() => |
51 | + '$runtimeType first:$firstChild last:$lastChild size:${childCrossAxis}x$childMainAxis'; | ||
51 | } | 52 | } |
52 | 53 | ||
53 | class GridView extends MultiChildWidget with SpanningWidget { | 54 | class GridView extends MultiChildWidget with SpanningWidget { |
@@ -73,7 +74,8 @@ class GridView extends MultiChildWidget with SpanningWidget { | @@ -73,7 +74,8 @@ class GridView extends MultiChildWidget with SpanningWidget { | ||
73 | int? _mainAxisCount; | 74 | int? _mainAxisCount; |
74 | 75 | ||
75 | @override | 76 | @override |
76 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 77 | + void layout(Context context, BoxConstraints constraints, |
78 | + {bool parentUsesSize = false}) { | ||
77 | if (children.isEmpty) { | 79 | if (children.isEmpty) { |
78 | box = PdfRect.zero; | 80 | box = PdfRect.zero; |
79 | return; | 81 | return; |
@@ -81,7 +83,8 @@ class GridView extends MultiChildWidget with SpanningWidget { | @@ -81,7 +83,8 @@ class GridView extends MultiChildWidget with SpanningWidget { | ||
81 | 83 | ||
82 | assert(() { | 84 | assert(() { |
83 | if (constraints.maxHeight.isInfinite && childAspectRatio.isInfinite) { | 85 | if (constraints.maxHeight.isInfinite && childAspectRatio.isInfinite) { |
84 | - print('Unable to calculate the GridView dimensions. Please set the height constraints or childAspectRatio.'); | 86 | + print( |
87 | + 'Unable to calculate the GridView dimensions. Please set the height constraints or childAspectRatio.'); | ||
85 | return false; | 88 | return false; |
86 | } | 89 | } |
87 | return true; | 90 | return true; |
@@ -102,19 +105,25 @@ class GridView extends MultiChildWidget with SpanningWidget { | @@ -102,19 +105,25 @@ class GridView extends MultiChildWidget with SpanningWidget { | ||
102 | } | 105 | } |
103 | 106 | ||
104 | if (constraints.maxHeight.isInfinite || _mainAxisCount == null) { | 107 | if (constraints.maxHeight.isInfinite || _mainAxisCount == null) { |
105 | - _mainAxisCount = ((children.length - _context.firstChild) / crossAxisCount).ceil(); | 108 | + _mainAxisCount = |
109 | + ((children.length - _context.firstChild) / crossAxisCount).ceil(); | ||
106 | 110 | ||
107 | - _context.childCrossAxis = | ||
108 | - crossAxisExtent / crossAxisCount - (crossAxisSpacing * (crossAxisCount - 1) / crossAxisCount); | 111 | + _context.childCrossAxis = crossAxisExtent / crossAxisCount - |
112 | + (crossAxisSpacing * (crossAxisCount - 1) / crossAxisCount); | ||
109 | 113 | ||
110 | - _context.childMainAxis = math.min(_context.childCrossAxis! * childAspectRatio, | ||
111 | - mainAxisExtent / _mainAxisCount! - (mainAxisSpacing * (_mainAxisCount! - 1) / _mainAxisCount!)); | 114 | + _context.childMainAxis = math.min( |
115 | + _context.childCrossAxis! * childAspectRatio, | ||
116 | + mainAxisExtent / _mainAxisCount! - | ||
117 | + (mainAxisSpacing * (_mainAxisCount! - 1) / _mainAxisCount!)); | ||
112 | 118 | ||
113 | if (_context.childCrossAxis!.isInfinite) { | 119 | if (_context.childCrossAxis!.isInfinite) { |
114 | - throw Exception('Unable to calculate child height as the height constraint is infinite.'); | 120 | + throw Exception( |
121 | + 'Unable to calculate child height as the height constraint is infinite.'); | ||
115 | } | 122 | } |
116 | } else { | 123 | } else { |
117 | - _mainAxisCount = ((mainAxisExtent + mainAxisSpacing) / (mainAxisSpacing + _context.childMainAxis!)).floor(); | 124 | + _mainAxisCount = ((mainAxisExtent + mainAxisSpacing) / |
125 | + (mainAxisSpacing + _context.childMainAxis!)) | ||
126 | + .floor(); | ||
118 | 127 | ||
119 | if (_mainAxisCount! < 0) { | 128 | if (_mainAxisCount! < 0) { |
120 | // Not enough space to put one line, try to ask for more space. | 129 | // Not enough space to put one line, try to ask for more space. |
@@ -122,8 +131,12 @@ class GridView extends MultiChildWidget with SpanningWidget { | @@ -122,8 +131,12 @@ class GridView extends MultiChildWidget with SpanningWidget { | ||
122 | } | 131 | } |
123 | } | 132 | } |
124 | 133 | ||
125 | - final totalMain = (_context.childMainAxis! + mainAxisSpacing) * _mainAxisCount! - mainAxisSpacing; | ||
126 | - final totalCross = (_context.childCrossAxis! + crossAxisSpacing) * crossAxisCount - crossAxisSpacing; | 134 | + final totalMain = |
135 | + (_context.childMainAxis! + mainAxisSpacing) * _mainAxisCount! - | ||
136 | + mainAxisSpacing; | ||
137 | + final totalCross = | ||
138 | + (_context.childCrossAxis! + crossAxisSpacing) * crossAxisCount - | ||
139 | + crossAxisSpacing; | ||
127 | 140 | ||
128 | final startX = resolvedPadding.left; | 141 | final startX = resolvedPadding.left; |
129 | const startY = 0.0; | 142 | const startY = 0.0; |
@@ -132,12 +145,14 @@ class GridView extends MultiChildWidget with SpanningWidget { | @@ -132,12 +145,14 @@ class GridView extends MultiChildWidget with SpanningWidget { | ||
132 | BoxConstraints? innerConstraints; | 145 | BoxConstraints? innerConstraints; |
133 | switch (direction) { | 146 | switch (direction) { |
134 | case Axis.vertical: | 147 | case Axis.vertical: |
135 | - innerConstraints = BoxConstraints.tightFor(width: _context.childCrossAxis, height: _context.childMainAxis); | 148 | + innerConstraints = BoxConstraints.tightFor( |
149 | + width: _context.childCrossAxis, height: _context.childMainAxis); | ||
136 | crossAxis = startX; | 150 | crossAxis = startX; |
137 | mainAxis = startY; | 151 | mainAxis = startY; |
138 | break; | 152 | break; |
139 | case Axis.horizontal: | 153 | case Axis.horizontal: |
140 | - innerConstraints = BoxConstraints.tightFor(width: _context.childMainAxis, height: _context.childCrossAxis); | 154 | + innerConstraints = BoxConstraints.tightFor( |
155 | + width: _context.childMainAxis, height: _context.childCrossAxis); | ||
141 | mainAxis = startX; | 156 | mainAxis = startX; |
142 | crossAxis = startY; | 157 | crossAxis = startY; |
143 | break; | 158 | break; |
@@ -148,7 +163,9 @@ class GridView extends MultiChildWidget with SpanningWidget { | @@ -148,7 +163,9 @@ class GridView extends MultiChildWidget with SpanningWidget { | ||
148 | 163 | ||
149 | final isRtl = textDirection == TextDirection.rtl; | 164 | final isRtl = textDirection == TextDirection.rtl; |
150 | for (final child in children.sublist( | 165 | for (final child in children.sublist( |
151 | - _context.firstChild, math.min(children.length, _context.firstChild + crossAxisCount * _mainAxisCount!))) { | 166 | + _context.firstChild, |
167 | + math.min(children.length, | ||
168 | + _context.firstChild + crossAxisCount * _mainAxisCount!))) { | ||
152 | child.layout(context, innerConstraints); | 169 | child.layout(context, innerConstraints); |
153 | assert(child.box != null); | 170 | assert(child.box != null); |
154 | 171 | ||
@@ -158,7 +175,8 @@ class GridView extends MultiChildWidget with SpanningWidget { | @@ -158,7 +175,8 @@ class GridView extends MultiChildWidget with SpanningWidget { | ||
158 | PdfPoint( | 175 | PdfPoint( |
159 | isRtl | 176 | isRtl |
160 | ? (_context.childCrossAxis! + child.box!.width - crossAxis) | 177 | ? (_context.childCrossAxis! + child.box!.width - crossAxis) |
161 | - : (_context.childCrossAxis! - child.box!.width) / 2.0 + crossAxis, | 178 | + : (_context.childCrossAxis! - child.box!.width) / 2.0 + |
179 | + crossAxis, | ||
162 | totalMain + | 180 | totalMain + |
163 | resolvedPadding.bottom - | 181 | resolvedPadding.bottom - |
164 | (_context.childMainAxis! - child.box!.height) / 2.0 - | 182 | (_context.childMainAxis! - child.box!.height) / 2.0 - |
@@ -172,8 +190,9 @@ class GridView extends MultiChildWidget with SpanningWidget { | @@ -172,8 +190,9 @@ class GridView extends MultiChildWidget with SpanningWidget { | ||
172 | child.box = PdfRect.fromPoints( | 190 | child.box = PdfRect.fromPoints( |
173 | PdfPoint( | 191 | PdfPoint( |
174 | isRtl | 192 | isRtl |
175 | - ? totalMain - (child.box!.width + mainAxis) | ||
176 | - : (_context.childMainAxis! - child.box!.width) / 2.0 + mainAxis, | 193 | + ? totalMain - (child.box!.width + mainAxis) |
194 | + : (_context.childMainAxis! - child.box!.width) / 2.0 + | ||
195 | + mainAxis, | ||
177 | totalCross + | 196 | totalCross + |
178 | resolvedPadding.bottom - | 197 | resolvedPadding.bottom - |
179 | (_context.childCrossAxis! - child.box!.height) / 2.0 - | 198 | (_context.childCrossAxis! - child.box!.height) / 2.0 - |
@@ -208,10 +227,14 @@ class GridView extends MultiChildWidget with SpanningWidget { | @@ -208,10 +227,14 @@ class GridView extends MultiChildWidget with SpanningWidget { | ||
208 | 227 | ||
209 | switch (direction) { | 228 | switch (direction) { |
210 | case Axis.vertical: | 229 | case Axis.vertical: |
211 | - box = constraints.constrainRect(width: totalCross + padding.horizontal, height: totalMain + padding.vertical); | 230 | + box = constraints.constrainRect( |
231 | + width: totalCross + padding.horizontal, | ||
232 | + height: totalMain + padding.vertical); | ||
212 | break; | 233 | break; |
213 | case Axis.horizontal: | 234 | case Axis.horizontal: |
214 | - box = constraints.constrainRect(width: totalMain + padding.horizontal, height: totalCross + padding.vertical); | 235 | + box = constraints.constrainRect( |
236 | + width: totalMain + padding.horizontal, | ||
237 | + height: totalCross + padding.vertical); | ||
215 | break; | 238 | break; |
216 | } | 239 | } |
217 | } | 240 | } |
@@ -231,25 +254,37 @@ class GridView extends MultiChildWidget with SpanningWidget { | @@ -231,25 +254,37 @@ class GridView extends MultiChildWidget with SpanningWidget { | ||
231 | ..lineTo(box!.right, box!.bottom) | 254 | ..lineTo(box!.right, box!.bottom) |
232 | ..lineTo(box!.right, box!.top) | 255 | ..lineTo(box!.right, box!.top) |
233 | ..lineTo(box!.left, box!.top) | 256 | ..lineTo(box!.left, box!.top) |
234 | - ..moveTo(box!.left + resolvedPadding.left, box!.bottom + resolvedPadding.bottom) | 257 | + ..moveTo(box!.left + resolvedPadding.left, |
258 | + box!.bottom + resolvedPadding.bottom) | ||
235 | ..lineTo(box!.left + resolvedPadding.left, box!.top - resolvedPadding.top) | 259 | ..lineTo(box!.left + resolvedPadding.left, box!.top - resolvedPadding.top) |
236 | - ..lineTo(box!.right - resolvedPadding.right, box!.top - resolvedPadding.top) | ||
237 | - ..lineTo(box!.right - resolvedPadding.right, box!.bottom + resolvedPadding.bottom) | 260 | + ..lineTo( |
261 | + box!.right - resolvedPadding.right, box!.top - resolvedPadding.top) | ||
262 | + ..lineTo(box!.right - resolvedPadding.right, | ||
263 | + box!.bottom + resolvedPadding.bottom) | ||
238 | ..fillPath(); | 264 | ..fillPath(); |
239 | 265 | ||
240 | for (var c = 1; c < crossAxisCount; c++) { | 266 | for (var c = 1; c < crossAxisCount; c++) { |
241 | switch (direction) { | 267 | switch (direction) { |
242 | case Axis.vertical: | 268 | case Axis.vertical: |
243 | context.canvas | 269 | context.canvas |
244 | - ..drawRect(box!.left + resolvedPadding.left + (_context.childCrossAxis! + crossAxisSpacing) * c - crossAxisSpacing, | ||
245 | - box!.bottom + resolvedPadding.bottom, math.max(crossAxisSpacing, 1), box!.height - resolvedPadding.vertical) | 270 | + ..drawRect( |
271 | + box!.left + | ||
272 | + resolvedPadding.left + | ||
273 | + (_context.childCrossAxis! + crossAxisSpacing) * c - | ||
274 | + crossAxisSpacing, | ||
275 | + box!.bottom + resolvedPadding.bottom, | ||
276 | + math.max(crossAxisSpacing, 1), | ||
277 | + box!.height - resolvedPadding.vertical) | ||
246 | ..fillPath(); | 278 | ..fillPath(); |
247 | break; | 279 | break; |
248 | case Axis.horizontal: | 280 | case Axis.horizontal: |
249 | context.canvas | 281 | context.canvas |
250 | ..drawRect( | 282 | ..drawRect( |
251 | box!.left + resolvedPadding.left, | 283 | box!.left + resolvedPadding.left, |
252 | - box!.bottom + resolvedPadding.bottom + (_context.childCrossAxis! + crossAxisSpacing) * c - crossAxisSpacing, | 284 | + box!.bottom + |
285 | + resolvedPadding.bottom + | ||
286 | + (_context.childCrossAxis! + crossAxisSpacing) * c - | ||
287 | + crossAxisSpacing, | ||
253 | box!.width - resolvedPadding.horizontal, | 288 | box!.width - resolvedPadding.horizontal, |
254 | math.max(crossAxisSpacing, 1)) | 289 | math.max(crossAxisSpacing, 1)) |
255 | ..fillPath(); | 290 | ..fillPath(); |
@@ -263,15 +298,24 @@ class GridView extends MultiChildWidget with SpanningWidget { | @@ -263,15 +298,24 @@ class GridView extends MultiChildWidget with SpanningWidget { | ||
263 | context.canvas | 298 | context.canvas |
264 | ..drawRect( | 299 | ..drawRect( |
265 | box!.left + resolvedPadding.left, | 300 | box!.left + resolvedPadding.left, |
266 | - box!.bottom + resolvedPadding.bottom + (_context.childMainAxis! + mainAxisSpacing) * c - mainAxisSpacing, | 301 | + box!.bottom + |
302 | + resolvedPadding.bottom + | ||
303 | + (_context.childMainAxis! + mainAxisSpacing) * c - | ||
304 | + mainAxisSpacing, | ||
267 | box!.width - resolvedPadding.horizontal, | 305 | box!.width - resolvedPadding.horizontal, |
268 | math.max(mainAxisSpacing, 1)) | 306 | math.max(mainAxisSpacing, 1)) |
269 | ..fillPath(); | 307 | ..fillPath(); |
270 | break; | 308 | break; |
271 | case Axis.horizontal: | 309 | case Axis.horizontal: |
272 | context.canvas | 310 | context.canvas |
273 | - ..drawRect(box!.left + resolvedPadding.left + (_context.childMainAxis! + mainAxisSpacing) * c - mainAxisSpacing, | ||
274 | - box!.bottom + resolvedPadding.bottom, math.max(mainAxisSpacing, 1), box!.height - resolvedPadding.vertical) | 311 | + ..drawRect( |
312 | + box!.left + | ||
313 | + resolvedPadding.left + | ||
314 | + (_context.childMainAxis! + mainAxisSpacing) * c - | ||
315 | + mainAxisSpacing, | ||
316 | + box!.bottom + resolvedPadding.bottom, | ||
317 | + math.max(mainAxisSpacing, 1), | ||
318 | + box!.height - resolvedPadding.vertical) | ||
275 | ..fillPath(); | 319 | ..fillPath(); |
276 | break; | 320 | break; |
277 | } | 321 | } |
@@ -288,7 +332,8 @@ class GridView extends MultiChildWidget with SpanningWidget { | @@ -288,7 +332,8 @@ class GridView extends MultiChildWidget with SpanningWidget { | ||
288 | ..saveContext() | 332 | ..saveContext() |
289 | ..setTransform(mat); | 333 | ..setTransform(mat); |
290 | 334 | ||
291 | - for (var child in children.sublist(_context.firstChild, _context.lastChild)) { | 335 | + for (var child |
336 | + in children.sublist(_context.firstChild, _context.lastChild)) { | ||
292 | child.paint(context); | 337 | child.paint(context); |
293 | } | 338 | } |
294 | context.canvas.restoreContext(); | 339 | context.canvas.restoreContext(); |
@@ -61,12 +61,14 @@ mixin SpanningWidget on Widget { | @@ -61,12 +61,14 @@ mixin SpanningWidget on Widget { | ||
61 | /// Called before relayout to restore the saved state and | 61 | /// Called before relayout to restore the saved state and |
62 | /// restart the layout in the same conditions | 62 | /// restart the layout in the same conditions |
63 | @protected | 63 | @protected |
64 | - void applyContext(covariant WidgetContext context) => saveContext().apply(context); | 64 | + void applyContext(covariant WidgetContext context) => |
65 | + saveContext().apply(context); | ||
65 | } | 66 | } |
66 | 67 | ||
67 | class NewPage extends Widget { | 68 | class NewPage extends Widget { |
68 | @override | 69 | @override |
69 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 70 | + void layout(Context context, BoxConstraints constraints, |
71 | + {bool parentUsesSize = false}) { | ||
70 | box = PdfRect.zero; | 72 | box = PdfRect.zero; |
71 | } | 73 | } |
72 | } | 74 | } |
@@ -183,7 +185,8 @@ class MultiPage extends Page { | @@ -183,7 +185,8 @@ class MultiPage extends Page { | ||
183 | /// This is not checked with a Release build. | 185 | /// This is not checked with a Release build. |
184 | final int maxPages; | 186 | final int maxPages; |
185 | 187 | ||
186 | - void _paintChild(Context context, Widget child, double x, double y, double pageHeight) { | 188 | + void _paintChild( |
189 | + Context context, Widget child, double x, double y, double pageHeight) { | ||
187 | if (mustRotate) { | 190 | if (mustRotate) { |
188 | final _margin = resolvedMargin!; | 191 | final _margin = resolvedMargin!; |
189 | context.canvas | 192 | context.canvas |
@@ -212,23 +215,30 @@ class MultiPage extends Page { | @@ -212,23 +215,30 @@ class MultiPage extends Page { | ||
212 | final _margin = resolvedMargin!; | 215 | final _margin = resolvedMargin!; |
213 | final _mustRotate = mustRotate; | 216 | final _mustRotate = mustRotate; |
214 | final pageHeight = _mustRotate ? pageFormat.width : pageFormat.height; | 217 | final pageHeight = _mustRotate ? pageFormat.width : pageFormat.height; |
215 | - final pageHeightMargin = _mustRotate ? _margin.horizontal : _margin.vertical; | 218 | + final pageHeightMargin = |
219 | + _mustRotate ? _margin.horizontal : _margin.vertical; | ||
216 | final constraints = BoxConstraints( | 220 | final constraints = BoxConstraints( |
217 | - maxWidth: _mustRotate ? (pageFormat.height - _margin.vertical) : (pageFormat.width - _margin.horizontal)); | 221 | + maxWidth: _mustRotate |
222 | + ? (pageFormat.height - _margin.vertical) | ||
223 | + : (pageFormat.width - _margin.horizontal)); | ||
218 | final fullConstraints = mustRotate | 224 | final fullConstraints = mustRotate |
219 | ? BoxConstraints( | 225 | ? BoxConstraints( |
220 | - maxWidth: pageFormat.height - _margin.vertical, maxHeight: pageFormat.width - _margin.horizontal) | 226 | + maxWidth: pageFormat.height - _margin.vertical, |
227 | + maxHeight: pageFormat.width - _margin.horizontal) | ||
221 | : BoxConstraints( | 228 | : BoxConstraints( |
222 | - maxWidth: pageFormat.width - _margin.horizontal, maxHeight: pageFormat.height - _margin.vertical); | 229 | + maxWidth: pageFormat.width - _margin.horizontal, |
230 | + maxHeight: pageFormat.height - _margin.vertical); | ||
223 | final calculatedTheme = theme ?? document.theme ?? ThemeData.base(); | 231 | final calculatedTheme = theme ?? document.theme ?? ThemeData.base(); |
224 | Context? context; | 232 | Context? context; |
225 | late double offsetEnd; | 233 | late double offsetEnd; |
226 | double? offsetStart; | 234 | double? offsetStart; |
227 | var _index = 0; | 235 | var _index = 0; |
228 | var sameCount = 0; | 236 | var sameCount = 0; |
229 | - final baseContext = Context(document: document.document).inheritFromAll(<Inherited>[ | 237 | + final baseContext = |
238 | + Context(document: document.document).inheritFromAll(<Inherited>[ | ||
230 | calculatedTheme, | 239 | calculatedTheme, |
231 | - if (pageTheme.textDirection != null) InheritedDirectionality(pageTheme.textDirection), | 240 | + if (pageTheme.textDirection != null) |
241 | + InheritedDirectionality(pageTheme.textDirection), | ||
232 | ]); | 242 | ]); |
233 | final children = _buildList(baseContext); | 243 | final children = _buildList(baseContext); |
234 | WidgetContext? widgetContext; | 244 | WidgetContext? widgetContext; |
@@ -263,8 +273,10 @@ class MultiPage extends Page { | @@ -263,8 +273,10 @@ class MultiPage extends Page { | ||
263 | return true; | 273 | return true; |
264 | }()); | 274 | }()); |
265 | 275 | ||
266 | - offsetStart = pageHeight - (_mustRotate ? pageHeightMargin - _margin.bottom : _margin.top); | ||
267 | - offsetEnd = _mustRotate ? pageHeightMargin - _margin.left : _margin.bottom; | 276 | + offsetStart = pageHeight - |
277 | + (_mustRotate ? pageHeightMargin - _margin.bottom : _margin.top); | ||
278 | + offsetEnd = | ||
279 | + _mustRotate ? pageHeightMargin - _margin.left : _margin.bottom; | ||
268 | 280 | ||
269 | _pages.add(_MultiPageInstance( | 281 | _pages.add(_MultiPageInstance( |
270 | context: context, | 282 | context: context, |
@@ -316,7 +328,8 @@ class MultiPage extends Page { | @@ -316,7 +328,8 @@ class MultiPage extends Page { | ||
316 | 328 | ||
317 | // Else we crash if the widget is too big and cannot be separated | 329 | // Else we crash if the widget is too big and cannot be separated |
318 | if (!canSpan) { | 330 | if (!canSpan) { |
319 | - throw Exception('Widget won\'t fit into the page as its height (${child.box!.height}) ' | 331 | + throw Exception( |
332 | + 'Widget won\'t fit into the page as its height (${child.box!.height}) ' | ||
320 | 'exceed a page height (${pageHeight - pageHeightMargin}). ' | 333 | 'exceed a page height (${pageHeight - pageHeightMargin}). ' |
321 | 'You probably need a SpanningWidget or use a single page layout'); | 334 | 'You probably need a SpanningWidget or use a single page layout'); |
322 | } | 335 | } |
@@ -328,7 +341,8 @@ class MultiPage extends Page { | @@ -328,7 +341,8 @@ class MultiPage extends Page { | ||
328 | span.applyContext(savedContext); | 341 | span.applyContext(savedContext); |
329 | } | 342 | } |
330 | 343 | ||
331 | - final localConstraints = constraints.copyWith(maxHeight: offsetStart - offsetEnd); | 344 | + final localConstraints = |
345 | + constraints.copyWith(maxHeight: offsetStart - offsetEnd); | ||
332 | span.layout(context, localConstraints, parentUsesSize: false); | 346 | span.layout(context, localConstraints, parentUsesSize: false); |
333 | assert(span.box != null); | 347 | assert(span.box != null); |
334 | widgetContext = span.saveContext(); | 348 | widgetContext = span.saveContext(); |
@@ -355,7 +369,8 @@ class MultiPage extends Page { | @@ -355,7 +369,8 @@ class MultiPage extends Page { | ||
355 | _MultiPageWidget( | 369 | _MultiPageWidget( |
356 | child: child, | 370 | child: child, |
357 | constraints: constraints, | 371 | constraints: constraints, |
358 | - widgetContext: child is SpanningWidget && canSpan ? child.cloneContext() : null, | 372 | + widgetContext: |
373 | + child is SpanningWidget && canSpan ? child.cloneContext() : null, | ||
359 | ), | 374 | ), |
360 | ); | 375 | ); |
361 | 376 | ||
@@ -371,21 +386,27 @@ class MultiPage extends Page { | @@ -371,21 +386,27 @@ class MultiPage extends Page { | ||
371 | final _mustRotate = mustRotate; | 386 | final _mustRotate = mustRotate; |
372 | final pageHeight = _mustRotate ? pageFormat.width : pageFormat.height; | 387 | final pageHeight = _mustRotate ? pageFormat.width : pageFormat.height; |
373 | final pageWidth = _mustRotate ? pageFormat.height : pageFormat.width; | 388 | final pageWidth = _mustRotate ? pageFormat.height : pageFormat.width; |
374 | - final pageHeightMargin = _mustRotate ? _margin.horizontal : _margin.vertical; | 389 | + final pageHeightMargin = |
390 | + _mustRotate ? _margin.horizontal : _margin.vertical; | ||
375 | final pageWidthMargin = _mustRotate ? _margin.vertical : _margin.horizontal; | 391 | final pageWidthMargin = _mustRotate ? _margin.vertical : _margin.horizontal; |
376 | final availableWidth = pageWidth - pageWidthMargin; | 392 | final availableWidth = pageWidth - pageWidthMargin; |
377 | final isRTL = pageTheme.textDirection == TextDirection.rtl; | 393 | final isRTL = pageTheme.textDirection == TextDirection.rtl; |
378 | for (final page in _pages) { | 394 | for (final page in _pages) { |
379 | - var offsetStart = pageHeight - (_mustRotate ? pageHeightMargin - _margin.bottom : _margin.top); | ||
380 | - var offsetEnd = _mustRotate ? pageHeightMargin - _margin.left : _margin.bottom; | 395 | + var offsetStart = pageHeight - |
396 | + (_mustRotate ? pageHeightMargin - _margin.bottom : _margin.top); | ||
397 | + var offsetEnd = | ||
398 | + _mustRotate ? pageHeightMargin - _margin.left : _margin.bottom; | ||
381 | 399 | ||
382 | if (pageTheme.buildBackground != null) { | 400 | if (pageTheme.buildBackground != null) { |
383 | final child = pageTheme.buildBackground!(page.context); | 401 | final child = pageTheme.buildBackground!(page.context); |
384 | 402 | ||
385 | child.layout(page.context, page.fullConstraints, parentUsesSize: false); | 403 | child.layout(page.context, page.fullConstraints, parentUsesSize: false); |
386 | assert(child.box != null); | 404 | assert(child.box != null); |
387 | - final xPos = isRTL ? _margin.left + (availableWidth - child.box!.width) : _margin.left; | ||
388 | - _paintChild(page.context, child, xPos, _margin.bottom, pageFormat.height); | 405 | + final xPos = isRTL |
406 | + ? _margin.left + (availableWidth - child.box!.width) | ||
407 | + : _margin.left; | ||
408 | + _paintChild( | ||
409 | + page.context, child, xPos, _margin.bottom, pageFormat.height); | ||
389 | } | 410 | } |
390 | 411 | ||
391 | var totalFlex = 0; | 412 | var totalFlex = 0; |
@@ -410,20 +431,28 @@ class MultiPage extends Page { | @@ -410,20 +431,28 @@ class MultiPage extends Page { | ||
410 | 431 | ||
411 | if (header != null) { | 432 | if (header != null) { |
412 | final headerWidget = header!(page.context); | 433 | final headerWidget = header!(page.context); |
413 | - headerWidget.layout(page.context, page.constraints, parentUsesSize: false); | 434 | + headerWidget.layout(page.context, page.constraints, |
435 | + parentUsesSize: false); | ||
414 | assert(headerWidget.box != null); | 436 | assert(headerWidget.box != null); |
415 | offsetStart -= headerWidget.box!.height; | 437 | offsetStart -= headerWidget.box!.height; |
416 | - final xPos = isRTL ? _margin.left + (availableWidth - headerWidget.box!.width) : _margin.left; | ||
417 | - _paintChild(page.context, headerWidget, xPos, page.offsetStart! - headerWidget.box!.height, pageFormat.height); | 438 | + final xPos = isRTL |
439 | + ? _margin.left + (availableWidth - headerWidget.box!.width) | ||
440 | + : _margin.left; | ||
441 | + _paintChild(page.context, headerWidget, xPos, | ||
442 | + page.offsetStart! - headerWidget.box!.height, pageFormat.height); | ||
418 | } | 443 | } |
419 | 444 | ||
420 | if (footer != null) { | 445 | if (footer != null) { |
421 | final footerWidget = footer!(page.context); | 446 | final footerWidget = footer!(page.context); |
422 | - footerWidget.layout(page.context, page.constraints, parentUsesSize: false); | 447 | + footerWidget.layout(page.context, page.constraints, |
448 | + parentUsesSize: false); | ||
423 | assert(footerWidget.box != null); | 449 | assert(footerWidget.box != null); |
424 | - final xPos = isRTL ? _margin.left + (availableWidth - footerWidget.box!.width) : _margin.left; | 450 | + final xPos = isRTL |
451 | + ? _margin.left + (availableWidth - footerWidget.box!.width) | ||
452 | + : _margin.left; | ||
425 | offsetEnd += footerWidget.box!.height; | 453 | offsetEnd += footerWidget.box!.height; |
426 | - _paintChild(page.context, footerWidget, xPos, _margin.bottom, pageFormat.height); | 454 | + _paintChild(page.context, footerWidget, xPos, _margin.bottom, |
455 | + pageFormat.height); | ||
427 | } | 456 | } |
428 | 457 | ||
429 | final freeSpace = math.max(0.0, offsetStart - offsetEnd - allocatedSize); | 458 | final freeSpace = math.max(0.0, offsetStart - offsetEnd - allocatedSize); |
@@ -452,14 +481,16 @@ class MultiPage extends Page { | @@ -452,14 +481,16 @@ class MultiPage extends Page { | ||
452 | break; | 481 | break; |
453 | case MainAxisAlignment.spaceBetween: | 482 | case MainAxisAlignment.spaceBetween: |
454 | leadingSpace = 0.0; | 483 | leadingSpace = 0.0; |
455 | - betweenSpace = totalChildren > 1 ? freeSpace / (totalChildren - 1) : 0.0; | 484 | + betweenSpace = |
485 | + totalChildren > 1 ? freeSpace / (totalChildren - 1) : 0.0; | ||
456 | break; | 486 | break; |
457 | case MainAxisAlignment.spaceAround: | 487 | case MainAxisAlignment.spaceAround: |
458 | betweenSpace = totalChildren > 0 ? freeSpace / totalChildren : 0.0; | 488 | betweenSpace = totalChildren > 0 ? freeSpace / totalChildren : 0.0; |
459 | leadingSpace = betweenSpace / 2.0; | 489 | leadingSpace = betweenSpace / 2.0; |
460 | break; | 490 | break; |
461 | case MainAxisAlignment.spaceEvenly: | 491 | case MainAxisAlignment.spaceEvenly: |
462 | - betweenSpace = totalChildren > 0 ? freeSpace / (totalChildren + 1) : 0.0; | 492 | + betweenSpace = |
493 | + totalChildren > 0 ? freeSpace / (totalChildren + 1) : 0.0; | ||
463 | leadingSpace = betweenSpace; | 494 | leadingSpace = betweenSpace; |
464 | break; | 495 | break; |
465 | } | 496 | } |
@@ -471,8 +502,11 @@ class MultiPage extends Page { | @@ -471,8 +502,11 @@ class MultiPage extends Page { | ||
471 | final flex = child is Flexible ? child.flex : 0; | 502 | final flex = child is Flexible ? child.flex : 0; |
472 | final fit = child is Flexible ? child.fit : FlexFit.loose; | 503 | final fit = child is Flexible ? child.fit : FlexFit.loose; |
473 | if (flex > 0) { | 504 | if (flex > 0) { |
474 | - assert(child is! SpanningWidget || child.canSpan == false, 'Cannot have a spanning widget flexible'); | ||
475 | - final maxChildExtent = child == lastFlexChild ? (freeSpace - allocatedFlexSpace) : spacePerFlex * flex; | 505 | + assert(child is! SpanningWidget || child.canSpan == false, |
506 | + 'Cannot have a spanning widget flexible'); | ||
507 | + final maxChildExtent = child == lastFlexChild | ||
508 | + ? (freeSpace - allocatedFlexSpace) | ||
509 | + : spacePerFlex * flex; | ||
476 | late double minChildExtent; | 510 | late double minChildExtent; |
477 | switch (fit) { | 511 | switch (fit) { |
478 | case FlexFit.tight: | 512 | case FlexFit.tight: |
@@ -526,7 +560,8 @@ class MultiPage extends Page { | @@ -526,7 +560,8 @@ class MultiPage extends Page { | ||
526 | if (child is SpanningWidget && child.canSpan) { | 560 | if (child is SpanningWidget && child.canSpan) { |
527 | child.applyContext(widget.widgetContext!); | 561 | child.applyContext(widget.widgetContext!); |
528 | } | 562 | } |
529 | - _paintChild(page.context, widget.child, _margin.left + x, pos, pageFormat.height); | 563 | + _paintChild(page.context, widget.child, _margin.left + x, pos, |
564 | + pageFormat.height); | ||
530 | pos -= betweenSpace; | 565 | pos -= betweenSpace; |
531 | } | 566 | } |
532 | 567 | ||
@@ -535,8 +570,11 @@ class MultiPage extends Page { | @@ -535,8 +570,11 @@ class MultiPage extends Page { | ||
535 | 570 | ||
536 | child.layout(page.context, page.fullConstraints, parentUsesSize: false); | 571 | child.layout(page.context, page.fullConstraints, parentUsesSize: false); |
537 | assert(child.box != null); | 572 | assert(child.box != null); |
538 | - final xPos = isRTL ? _margin.left + (availableWidth - child.box!.width) : _margin.left; | ||
539 | - _paintChild(page.context, child, xPos, _margin.bottom, pageFormat.height); | 573 | + final xPos = isRTL |
574 | + ? _margin.left + (availableWidth - child.box!.width) | ||
575 | + : _margin.left; | ||
576 | + _paintChild( | ||
577 | + page.context, child, xPos, _margin.bottom, pageFormat.height); | ||
540 | } | 578 | } |
541 | } | 579 | } |
542 | } | 580 | } |
@@ -93,7 +93,8 @@ class Page { | @@ -93,7 +93,8 @@ class Page { | ||
93 | ..lineTo(0, pageFormat.height) | 93 | ..lineTo(0, pageFormat.height) |
94 | ..moveTo(_margin.left, _margin.bottom) | 94 | ..moveTo(_margin.left, _margin.bottom) |
95 | ..lineTo(_margin.left, pageFormat.height - _margin.top) | 95 | ..lineTo(_margin.left, pageFormat.height - _margin.top) |
96 | - ..lineTo(pageFormat.width - _margin.right, pageFormat.height - _margin.top) | 96 | + ..lineTo( |
97 | + pageFormat.width - _margin.right, pageFormat.height - _margin.top) | ||
97 | ..lineTo(pageFormat.width - _margin.right, _margin.bottom) | 98 | ..lineTo(pageFormat.width - _margin.right, _margin.bottom) |
98 | ..fillPath(); | 99 | ..fillPath(); |
99 | } | 100 | } |
@@ -101,7 +102,8 @@ class Page { | @@ -101,7 +102,8 @@ class Page { | ||
101 | void generate(Document document, {bool insert = true, int? index}) { | 102 | void generate(Document document, {bool insert = true, int? index}) { |
102 | if (index != null) { | 103 | if (index != null) { |
103 | if (insert) { | 104 | if (insert) { |
104 | - _pdfPage = PdfPage(document.document, pageFormat: pageFormat, index: index); | 105 | + _pdfPage = |
106 | + PdfPage(document.document, pageFormat: pageFormat, index: index); | ||
105 | } else { | 107 | } else { |
106 | _pdfPage = document.document.page(index); | 108 | _pdfPage = document.document.page(index); |
107 | } | 109 | } |
@@ -116,9 +118,11 @@ class Page { | @@ -116,9 +118,11 @@ class Page { | ||
116 | final _margin = resolvedMargin; | 118 | final _margin = resolvedMargin; |
117 | var constraints = mustRotate | 119 | var constraints = mustRotate |
118 | ? BoxConstraints( | 120 | ? BoxConstraints( |
119 | - maxWidth: pageFormat.height - _margin!.vertical, maxHeight: pageFormat.width - _margin.horizontal) | 121 | + maxWidth: pageFormat.height - _margin!.vertical, |
122 | + maxHeight: pageFormat.width - _margin.horizontal) | ||
120 | : BoxConstraints( | 123 | : BoxConstraints( |
121 | - maxWidth: pageFormat.width - _margin!.horizontal, maxHeight: pageFormat.height - _margin.vertical); | 124 | + maxWidth: pageFormat.width - _margin!.horizontal, |
125 | + maxHeight: pageFormat.height - _margin.vertical); | ||
122 | 126 | ||
123 | final calculatedTheme = theme ?? document.theme ?? ThemeData.base(); | 127 | final calculatedTheme = theme ?? document.theme ?? ThemeData.base(); |
124 | final context = Context( | 128 | final context = Context( |
@@ -127,7 +131,8 @@ class Page { | @@ -127,7 +131,8 @@ class Page { | ||
127 | canvas: canvas, | 131 | canvas: canvas, |
128 | ).inheritFromAll(<Inherited>[ | 132 | ).inheritFromAll(<Inherited>[ |
129 | calculatedTheme, | 133 | calculatedTheme, |
130 | - if (pageTheme.textDirection != null) InheritedDirectionality(pageTheme.textDirection), | 134 | + if (pageTheme.textDirection != null) |
135 | + InheritedDirectionality(pageTheme.textDirection), | ||
131 | ]); | 136 | ]); |
132 | 137 | ||
133 | Widget? background; | 138 | Widget? background; |
@@ -139,7 +144,8 @@ class Page { | @@ -139,7 +144,8 @@ class Page { | ||
139 | final size = layout(content, context, constraints); | 144 | final size = layout(content, context, constraints); |
140 | 145 | ||
141 | if (_pdfPage!.pageFormat.height == double.infinity) { | 146 | if (_pdfPage!.pageFormat.height == double.infinity) { |
142 | - _pdfPage!.pageFormat = _pdfPage!.pageFormat.copyWith(width: size.x, height: size.y); | 147 | + _pdfPage!.pageFormat = |
148 | + _pdfPage!.pageFormat.copyWith(width: size.x, height: size.y); | ||
143 | constraints = mustRotate | 149 | constraints = mustRotate |
144 | ? BoxConstraints( | 150 | ? BoxConstraints( |
145 | maxWidth: _pdfPage!.pageFormat.height - _margin.vertical, | 151 | maxWidth: _pdfPage!.pageFormat.height - _margin.vertical, |
@@ -178,18 +184,22 @@ class Page { | @@ -178,18 +184,22 @@ class Page { | ||
178 | } | 184 | } |
179 | 185 | ||
180 | @protected | 186 | @protected |
181 | - PdfPoint layout(Widget child, Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 187 | + PdfPoint layout(Widget child, Context context, BoxConstraints constraints, |
188 | + {bool parentUsesSize = false}) { | ||
182 | final _margin = resolvedMargin!; | 189 | final _margin = resolvedMargin!; |
183 | child.layout(context, constraints, parentUsesSize: parentUsesSize); | 190 | child.layout(context, constraints, parentUsesSize: parentUsesSize); |
184 | assert(child.box != null); | 191 | assert(child.box != null); |
185 | 192 | ||
186 | - final width = | ||
187 | - pageFormat.width == double.infinity ? child.box!.width + _margin.left + _margin.right : pageFormat.width; | 193 | + final width = pageFormat.width == double.infinity |
194 | + ? child.box!.width + _margin.left + _margin.right | ||
195 | + : pageFormat.width; | ||
188 | 196 | ||
189 | - final height = | ||
190 | - pageFormat.height == double.infinity ? child.box!.height + _margin.top + _margin.bottom : pageFormat.height; | 197 | + final height = pageFormat.height == double.infinity |
198 | + ? child.box!.height + _margin.top + _margin.bottom | ||
199 | + : pageFormat.height; | ||
191 | 200 | ||
192 | - child.box = PdfRect(_margin.left, height - child.box!.height - _margin.top, child.box!.width, child.box!.height); | 201 | + child.box = PdfRect(_margin.left, height - child.box!.height - _margin.top, |
202 | + child.box!.width, child.box!.height); | ||
193 | 203 | ||
194 | return PdfPoint(width, height); | 204 | return PdfPoint(width, height); |
195 | } | 205 | } |
@@ -212,7 +222,8 @@ class Page { | @@ -212,7 +222,8 @@ class Page { | ||
212 | 222 | ||
213 | if (pageTheme.textDirection == TextDirection.rtl) { | 223 | if (pageTheme.textDirection == TextDirection.rtl) { |
214 | child.box = PdfRect( | 224 | child.box = PdfRect( |
215 | - ((mustRotate ? box.height : box.width) - child.box!.width) + child.box!.x, | 225 | + ((mustRotate ? box.height : box.width) - child.box!.width) + |
226 | + child.box!.x, | ||
216 | child.box!.y, | 227 | child.box!.y, |
217 | child.box!.width, | 228 | child.box!.width, |
218 | child.box!.height, | 229 | child.box!.height, |
@@ -54,8 +54,10 @@ class PageTheme { | @@ -54,8 +54,10 @@ class PageTheme { | ||
54 | final TextDirection? textDirection; | 54 | final TextDirection? textDirection; |
55 | 55 | ||
56 | bool get mustRotate => | 56 | bool get mustRotate => |
57 | - (orientation == PageOrientation.landscape && pageFormat.height > pageFormat.width) || | ||
58 | - (orientation == PageOrientation.portrait && pageFormat.width > pageFormat.height); | 57 | + (orientation == PageOrientation.landscape && |
58 | + pageFormat.height > pageFormat.width) || | ||
59 | + (orientation == PageOrientation.portrait && | ||
60 | + pageFormat.width > pageFormat.height); | ||
59 | 61 | ||
60 | EdgeInsetsGeometry? get margin { | 62 | EdgeInsetsGeometry? get margin { |
61 | if (_margin != null) { | 63 | if (_margin != null) { |
@@ -73,11 +75,11 @@ class PageTheme { | @@ -73,11 +75,11 @@ class PageTheme { | ||
73 | } | 75 | } |
74 | 76 | ||
75 | if (mustRotate) { | 77 | if (mustRotate) { |
76 | - return EdgeInsets.fromLTRB( | ||
77 | - pageFormat.marginBottom, pageFormat.marginLeft, pageFormat.marginTop, pageFormat.marginRight); | 78 | + return EdgeInsets.fromLTRB(pageFormat.marginBottom, pageFormat.marginLeft, |
79 | + pageFormat.marginTop, pageFormat.marginRight); | ||
78 | } else { | 80 | } else { |
79 | - return EdgeInsets.fromLTRB( | ||
80 | - pageFormat.marginLeft, pageFormat.marginTop, pageFormat.marginRight, pageFormat.marginBottom); | 81 | + return EdgeInsets.fromLTRB(pageFormat.marginLeft, pageFormat.marginTop, |
82 | + pageFormat.marginRight, pageFormat.marginBottom); | ||
81 | } | 83 | } |
82 | } | 84 | } |
83 | 85 |
@@ -146,7 +146,8 @@ class PositionedDirectional extends Positioned { | @@ -146,7 +146,8 @@ class PositionedDirectional extends Positioned { | ||
146 | final double? end; | 146 | final double? end; |
147 | 147 | ||
148 | @override | 148 | @override |
149 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 149 | + void layout(Context context, BoxConstraints constraints, |
150 | + {bool parentUsesSize = false}) { | ||
150 | super.layout(context, constraints, parentUsesSize: parentUsesSize); | 151 | super.layout(context, constraints, parentUsesSize: parentUsesSize); |
151 | switch (Directionality.of(context)) { | 152 | switch (Directionality.of(context)) { |
152 | case TextDirection.rtl: | 153 | case TextDirection.rtl: |
@@ -181,7 +182,8 @@ class Stack extends MultiChildWidget { | @@ -181,7 +182,8 @@ class Stack extends MultiChildWidget { | ||
181 | final Overflow overflow; | 182 | final Overflow overflow; |
182 | 183 | ||
183 | @override | 184 | @override |
184 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 185 | + void layout(Context context, BoxConstraints constraints, |
186 | + {bool parentUsesSize = false}) { | ||
185 | final childCount = children.length; | 187 | final childCount = children.length; |
186 | 188 | ||
187 | var hasNonPositionedChildren = false; | 189 | var hasNonPositionedChildren = false; |
@@ -230,22 +232,27 @@ class Stack extends MultiChildWidget { | @@ -230,22 +232,27 @@ class Stack extends MultiChildWidget { | ||
230 | final resolvedAlignment = alignment.resolve(Directionality.of(context)); | 232 | final resolvedAlignment = alignment.resolve(Directionality.of(context)); |
231 | for (final child in children) { | 233 | for (final child in children) { |
232 | if (child is! Positioned) { | 234 | if (child is! Positioned) { |
233 | - child.box = PdfRect.fromPoints(resolvedAlignment.inscribe(child.box!.size, box!).offset, child.box!.size); | 235 | + child.box = PdfRect.fromPoints( |
236 | + resolvedAlignment.inscribe(child.box!.size, box!).offset, | ||
237 | + child.box!.size); | ||
234 | } else { | 238 | } else { |
235 | final positioned = child; | 239 | final positioned = child; |
236 | 240 | ||
237 | var childConstraints = const BoxConstraints(); | 241 | var childConstraints = const BoxConstraints(); |
238 | 242 | ||
239 | if (positioned.left != null && positioned.right != null) { | 243 | if (positioned.left != null && positioned.right != null) { |
240 | - childConstraints = childConstraints.tighten(width: box!.width - positioned.right! - positioned.left!); | 244 | + childConstraints = childConstraints.tighten( |
245 | + width: box!.width - positioned.right! - positioned.left!); | ||
241 | } else if (positioned.width != null) { | 246 | } else if (positioned.width != null) { |
242 | childConstraints = childConstraints.tighten(width: positioned.width); | 247 | childConstraints = childConstraints.tighten(width: positioned.width); |
243 | } | 248 | } |
244 | 249 | ||
245 | if (positioned.top != null && positioned.bottom != null) { | 250 | if (positioned.top != null && positioned.bottom != null) { |
246 | - childConstraints = childConstraints.tighten(height: box!.height - positioned.bottom! - positioned.top!); | 251 | + childConstraints = childConstraints.tighten( |
252 | + height: box!.height - positioned.bottom! - positioned.top!); | ||
247 | } else if (positioned.height != null) { | 253 | } else if (positioned.height != null) { |
248 | - childConstraints = childConstraints.tighten(height: positioned.height); | 254 | + childConstraints = |
255 | + childConstraints.tighten(height: positioned.height); | ||
249 | } | 256 | } |
250 | 257 | ||
251 | positioned.layout(context, childConstraints, parentUsesSize: true); | 258 | positioned.layout(context, childConstraints, parentUsesSize: true); |
@@ -269,7 +276,8 @@ class Stack extends MultiChildWidget { | @@ -269,7 +276,8 @@ class Stack extends MultiChildWidget { | ||
269 | y = resolvedAlignment.inscribe(positioned.box!.size, box!).y; | 276 | y = resolvedAlignment.inscribe(positioned.box!.size, box!).y; |
270 | } | 277 | } |
271 | 278 | ||
272 | - positioned.box = PdfRect.fromPoints(PdfPoint(x!, y!), positioned.box!.size); | 279 | + positioned.box = |
280 | + PdfRect.fromPoints(PdfPoint(x!, y!), positioned.box!.size); | ||
273 | } | 281 | } |
274 | } | 282 | } |
275 | } | 283 | } |
@@ -120,7 +120,8 @@ mixin TableHelper { | @@ -120,7 +120,8 @@ mixin TableHelper { | ||
120 | rowNum++; | 120 | rowNum++; |
121 | } | 121 | } |
122 | 122 | ||
123 | - final textDirection = context == null ? TextDirection.ltr : Directionality.of(context); | 123 | + final textDirection = |
124 | + context == null ? TextDirection.ltr : Directionality.of(context); | ||
124 | for (final row in data) { | 125 | for (final row in data) { |
125 | final tableRow = <Widget>[]; | 126 | final tableRow = <Widget>[]; |
126 | final isOdd = (rowNum - headerCount) % 2 != 0; | 127 | final isOdd = (rowNum - headerCount) % 2 != 0; |
@@ -83,7 +83,8 @@ abstract class _Span { | @@ -83,7 +83,8 @@ abstract class _Span { | ||
83 | } | 83 | } |
84 | 84 | ||
85 | class _TextDecoration { | 85 | class _TextDecoration { |
86 | - _TextDecoration(this.style, this.annotation, this.startSpan, this.endSpan) : assert(startSpan <= endSpan); | 86 | + _TextDecoration(this.style, this.annotation, this.startSpan, this.endSpan) |
87 | + : assert(startSpan <= endSpan); | ||
87 | 88 | ||
88 | static const double _space = -0.15; | 89 | static const double _space = -0.15; |
89 | 90 | ||
@@ -103,7 +104,8 @@ class _TextDecoration { | @@ -103,7 +104,8 @@ class _TextDecoration { | ||
103 | } | 104 | } |
104 | 105 | ||
105 | final x1 = spans[startSpan].offset.x + spans[startSpan].left; | 106 | final x1 = spans[startSpan].offset.x + spans[startSpan].left; |
106 | - final x2 = spans[endSpan].offset.x + spans[endSpan].left + spans[endSpan].width; | 107 | + final x2 = |
108 | + spans[endSpan].offset.x + spans[endSpan].left + spans[endSpan].width; | ||
107 | var y1 = spans[startSpan].offset.y + spans[startSpan].top; | 109 | var y1 = spans[startSpan].offset.y + spans[startSpan].top; |
108 | var y2 = y1 + spans[startSpan].height; | 110 | var y2 = y1 + spans[startSpan].height; |
109 | 111 | ||
@@ -118,7 +120,8 @@ class _TextDecoration { | @@ -118,7 +120,8 @@ class _TextDecoration { | ||
118 | return _box; | 120 | return _box; |
119 | } | 121 | } |
120 | 122 | ||
121 | - _TextDecoration copyWith({int? endSpan}) => _TextDecoration(style, annotation, startSpan, endSpan ?? this.endSpan); | 123 | + _TextDecoration copyWith({int? endSpan}) => |
124 | + _TextDecoration(style, annotation, startSpan, endSpan ?? this.endSpan); | ||
122 | 125 | ||
123 | void backgroundPaint( | 126 | void backgroundPaint( |
124 | Context context, | 127 | Context context, |
@@ -163,11 +166,15 @@ class _TextDecoration { | @@ -163,11 +166,15 @@ class _TextDecoration { | ||
163 | final box = _getBox(spans); | 166 | final box = _getBox(spans); |
164 | 167 | ||
165 | final font = style.font!.getFont(context); | 168 | final font = style.font!.getFont(context); |
166 | - final space = _space * style.fontSize! * textScaleFactor * style.decorationThickness!; | 169 | + final space = |
170 | + _space * style.fontSize! * textScaleFactor * style.decorationThickness!; | ||
167 | 171 | ||
168 | context.canvas | 172 | context.canvas |
169 | ..setStrokeColor(style.decorationColor ?? style.color) | 173 | ..setStrokeColor(style.decorationColor ?? style.color) |
170 | - ..setLineWidth(style.decorationThickness! * style.fontSize! * textScaleFactor * 0.05); | 174 | + ..setLineWidth(style.decorationThickness! * |
175 | + style.fontSize! * | ||
176 | + textScaleFactor * | ||
177 | + 0.05); | ||
171 | 178 | ||
172 | if (style.decoration!.contains(TextDecoration.underline)) { | 179 | if (style.decoration!.contains(TextDecoration.underline)) { |
173 | final base = -font.descent * style.fontSize! * textScaleFactor / 2; | 180 | final base = -font.descent * style.fontSize! * textScaleFactor / 2; |
@@ -240,7 +247,8 @@ class _TextDecoration { | @@ -240,7 +247,8 @@ class _TextDecoration { | ||
240 | 247 | ||
241 | context.canvas | 248 | context.canvas |
242 | ..setLineWidth(.5) | 249 | ..setLineWidth(.5) |
243 | - ..drawRect(globalBox.x + box.x, globalBox.top + box.y, box.width, box.height) | 250 | + ..drawRect( |
251 | + globalBox.x + box.x, globalBox.top + box.y, box.width, box.height) | ||
244 | ..setStrokeColor(PdfColors.yellow) | 252 | ..setStrokeColor(PdfColors.yellow) |
245 | ..strokePath(); | 253 | ..strokePath(); |
246 | } | 254 | } |
@@ -302,11 +310,14 @@ class _Word extends _Span { | @@ -302,11 +310,14 @@ class _Word extends _Span { | ||
302 | 310 | ||
303 | context.canvas | 311 | context.canvas |
304 | ..setLineWidth(.5) | 312 | ..setLineWidth(.5) |
305 | - ..drawRect( | ||
306 | - globalBox!.x + offset.x + metrics.left, globalBox.top + offset.y + metrics.top, metrics.width, metrics.height) | 313 | + ..drawRect(globalBox!.x + offset.x + metrics.left, |
314 | + globalBox.top + offset.y + metrics.top, metrics.width, metrics.height) | ||
307 | ..setStrokeColor(PdfColors.orange) | 315 | ..setStrokeColor(PdfColors.orange) |
308 | ..strokePath() | 316 | ..strokePath() |
309 | - ..drawLine(globalBox.x + offset.x - deb, globalBox.top + offset.y, globalBox.x + offset.x + metrics.right + deb, | 317 | + ..drawLine( |
318 | + globalBox.x + offset.x - deb, | ||
319 | + globalBox.top + offset.y, | ||
320 | + globalBox.x + offset.x + metrics.right + deb, | ||
310 | globalBox.top + offset.y) | 321 | globalBox.top + offset.y) |
311 | ..setStrokeColor(PdfColors.deepPurple) | 322 | ..setStrokeColor(PdfColors.deepPurple) |
312 | ..strokePath(); | 323 | ..strokePath(); |
@@ -352,8 +363,10 @@ class _WidgetSpan extends _Span { | @@ -352,8 +363,10 @@ class _WidgetSpan extends _Span { | ||
352 | double textScaleFactor, | 363 | double textScaleFactor, |
353 | PdfPoint point, | 364 | PdfPoint point, |
354 | ) { | 365 | ) { |
355 | - widget.box = | ||
356 | - PdfRect.fromPoints(PdfPoint(point.x + widget.box!.offset.x, point.y + widget.box!.offset.y), widget.box!.size); | 366 | + widget.box = PdfRect.fromPoints( |
367 | + PdfPoint( | ||
368 | + point.x + widget.box!.offset.x, point.y + widget.box!.offset.y), | ||
369 | + widget.box!.size); | ||
357 | widget.paint(context); | 370 | widget.paint(context); |
358 | } | 371 | } |
359 | 372 | ||
@@ -367,7 +380,8 @@ class _WidgetSpan extends _Span { | @@ -367,7 +380,8 @@ class _WidgetSpan extends _Span { | ||
367 | 380 | ||
368 | context.canvas | 381 | context.canvas |
369 | ..setLineWidth(.5) | 382 | ..setLineWidth(.5) |
370 | - ..drawRect(globalBox!.x + offset.x, globalBox.top + offset.y, width, height) | 383 | + ..drawRect( |
384 | + globalBox!.x + offset.x, globalBox.top + offset.y, width, height) | ||
371 | ..setStrokeColor(PdfColors.orange) | 385 | ..setStrokeColor(PdfColors.orange) |
372 | ..strokePath() | 386 | ..strokePath() |
373 | ..drawLine( | 387 | ..drawLine( |
@@ -550,11 +564,14 @@ class _Line { | @@ -550,11 +564,14 @@ class _Line { | ||
550 | 564 | ||
551 | double get height { | 565 | double get height { |
552 | final list = parent._spans.sublist(firstSpan, lastSpan); | 566 | final list = parent._spans.sublist(firstSpan, lastSpan); |
553 | - return list.isEmpty ? 0 : list.reduce((a, b) => a.height > b.height ? a : b).height; | 567 | + return list.isEmpty |
568 | + ? 0 | ||
569 | + : list.reduce((a, b) => a.height > b.height ? a : b).height; | ||
554 | } | 570 | } |
555 | 571 | ||
556 | @override | 572 | @override |
557 | - String toString() => '$runtimeType $firstSpan-$lastSpan baseline: $baseline width:$wordsWidth'; | 573 | + String toString() => |
574 | + '$runtimeType $firstSpan-$lastSpan baseline: $baseline width:$wordsWidth'; | ||
558 | 575 | ||
559 | void realign(double totalWidth) { | 576 | void realign(double totalWidth) { |
560 | final spans = parent._spans.sublist(firstSpan, lastSpan); | 577 | final spans = parent._spans.sublist(firstSpan, lastSpan); |
@@ -566,7 +583,7 @@ class _Line { | @@ -566,7 +583,7 @@ class _Line { | ||
566 | delta = isRTL ? wordsWidth : 0; | 583 | delta = isRTL ? wordsWidth : 0; |
567 | break; | 584 | break; |
568 | case TextAlign.right: | 585 | case TextAlign.right: |
569 | - delta = isRTL ? totalWidth: totalWidth - wordsWidth; | 586 | + delta = isRTL ? totalWidth : totalWidth - wordsWidth; |
570 | break; | 587 | break; |
571 | case TextAlign.start: | 588 | case TextAlign.start: |
572 | delta = isRTL ? totalWidth : 0; | 589 | delta = isRTL ? totalWidth : 0; |
@@ -576,7 +593,7 @@ class _Line { | @@ -576,7 +593,7 @@ class _Line { | ||
576 | break; | 593 | break; |
577 | case TextAlign.center: | 594 | case TextAlign.center: |
578 | delta = (totalWidth - wordsWidth) / 2.0; | 595 | delta = (totalWidth - wordsWidth) / 2.0; |
579 | - if(isRTL) { | 596 | + if (isRTL) { |
580 | delta += wordsWidth; | 597 | delta += wordsWidth; |
581 | } | 598 | } |
582 | break; | 599 | break; |
@@ -590,7 +607,9 @@ class _Line { | @@ -590,7 +607,9 @@ class _Line { | ||
590 | var x = 0.0; | 607 | var x = 0.0; |
591 | for (final span in spans) { | 608 | for (final span in spans) { |
592 | span.offset = PdfPoint( | 609 | span.offset = PdfPoint( |
593 | - isRTL ? delta - x - (span.offset.x + span.width) : span.offset.x + x, | 610 | + isRTL |
611 | + ? delta - x - (span.offset.x + span.width) | ||
612 | + : span.offset.x + x, | ||
594 | span.offset.y - baseline, | 613 | span.offset.y - baseline, |
595 | ); | 614 | ); |
596 | x += gap; | 615 | x += gap; |
@@ -635,7 +654,8 @@ class RichTextContext extends WidgetContext { | @@ -635,7 +654,8 @@ class RichTextContext extends WidgetContext { | ||
635 | } | 654 | } |
636 | 655 | ||
637 | @override | 656 | @override |
638 | - String toString() => '$runtimeType Offset: $startOffset -> $endOffset Span: $spanStart -> $spanEnd'; | 657 | + String toString() => |
658 | + '$runtimeType Offset: $startOffset -> $endOffset Span: $spanStart -> $spanEnd'; | ||
639 | } | 659 | } |
640 | 660 | ||
641 | class RichText extends Widget with SpanningWidget { | 661 | class RichText extends Widget with SpanningWidget { |
@@ -684,7 +704,8 @@ class RichText extends Widget with SpanningWidget { | @@ -684,7 +704,8 @@ class RichText extends Widget with SpanningWidget { | ||
684 | if (append && _decorations.isNotEmpty) { | 704 | if (append && _decorations.isNotEmpty) { |
685 | final last = _decorations.last; | 705 | final last = _decorations.last; |
686 | if (last.style == td.style && last.annotation == td.annotation) { | 706 | if (last.style == td.style && last.annotation == td.annotation) { |
687 | - _decorations[_decorations.length - 1] = last.copyWith(endSpan: td.endSpan); | 707 | + _decorations[_decorations.length - 1] = |
708 | + last.copyWith(endSpan: td.endSpan); | ||
688 | return; | 709 | return; |
689 | } | 710 | } |
690 | } | 711 | } |
@@ -854,7 +875,8 @@ class RichText extends Widget with SpanningWidget { | @@ -854,7 +875,8 @@ class RichText extends Widget with SpanningWidget { | ||
854 | } | 875 | } |
855 | 876 | ||
856 | @override | 877 | @override |
857 | - void layout(Context context, BoxConstraints constraints, {bool parentUsesSize = false}) { | 878 | + void layout(Context context, BoxConstraints constraints, |
879 | + {bool parentUsesSize = false}) { | ||
858 | _spans.clear(); | 880 | _spans.clear(); |
859 | _decorations.clear(); | 881 | _decorations.clear(); |
860 | 882 | ||
@@ -866,8 +888,12 @@ class RichText extends Widget with SpanningWidget { | @@ -866,8 +888,12 @@ class RichText extends Widget with SpanningWidget { | ||
866 | 888 | ||
867 | final _overflow = this.overflow ?? theme.overflow; | 889 | final _overflow = this.overflow ?? theme.overflow; |
868 | 890 | ||
869 | - final constraintWidth = constraints.hasBoundedWidth ? constraints.maxWidth : constraints.constrainWidth(); | ||
870 | - final constraintHeight = constraints.hasBoundedHeight ? constraints.maxHeight : constraints.constrainHeight(); | 891 | + final constraintWidth = constraints.hasBoundedWidth |
892 | + ? constraints.maxWidth | ||
893 | + : constraints.constrainWidth(); | ||
894 | + final constraintHeight = constraints.hasBoundedHeight | ||
895 | + ? constraints.maxHeight | ||
896 | + : constraints.constrainHeight(); | ||
871 | 897 | ||
872 | var offsetX = 0.0; | 898 | var offsetX = 0.0; |
873 | var offsetY = _context.startOffset; | 899 | var offsetY = _context.startOffset; |
@@ -894,10 +920,13 @@ class RichText extends Widget with SpanningWidget { | @@ -894,10 +920,13 @@ class RichText extends Widget with SpanningWidget { | ||
894 | 920 | ||
895 | final font = style!.font!.getFont(context); | 921 | final font = style!.font!.getFont(context); |
896 | 922 | ||
897 | - final space = font.stringMetrics(' ') * (style.fontSize! * textScaleFactor); | 923 | + final space = |
924 | + font.stringMetrics(' ') * (style.fontSize! * textScaleFactor); | ||
898 | 925 | ||
899 | - final spanLines = | ||
900 | - (_textDirection == TextDirection.rtl ? bidi.logicalToVisual(span.text!) : span.text)!.split('\n'); | 926 | + final spanLines = (_textDirection == TextDirection.rtl |
927 | + ? bidi.logicalToVisual(span.text!) | ||
928 | + : span.text)! | ||
929 | + .split('\n'); | ||
901 | 930 | ||
902 | for (var line = 0; line < spanLines.length; line++) { | 931 | for (var line = 0; line < spanLines.length; line++) { |
903 | final words = spanLines[line].split(RegExp(r'\s')); | 932 | final words = spanLines[line].split(RegExp(r'\s')); |
@@ -905,15 +934,18 @@ class RichText extends Widget with SpanningWidget { | @@ -905,15 +934,18 @@ class RichText extends Widget with SpanningWidget { | ||
905 | final word = words[index]; | 934 | final word = words[index]; |
906 | 935 | ||
907 | if (word.isEmpty) { | 936 | if (word.isEmpty) { |
908 | - offsetX += space.advanceWidth * style.wordSpacing! + style.letterSpacing!; | 937 | + offsetX += space.advanceWidth * style.wordSpacing! + |
938 | + style.letterSpacing!; | ||
909 | continue; | 939 | continue; |
910 | } | 940 | } |
911 | 941 | ||
912 | - final metrics = | ||
913 | - font.stringMetrics(word, letterSpacing: style.letterSpacing! / (style.fontSize! * textScaleFactor)) * | ||
914 | - (style.fontSize! * textScaleFactor); | 942 | + final metrics = font.stringMetrics(word, |
943 | + letterSpacing: style.letterSpacing! / | ||
944 | + (style.fontSize! * textScaleFactor)) * | ||
945 | + (style.fontSize! * textScaleFactor); | ||
915 | 946 | ||
916 | - if (_softWrap && offsetX + metrics.width > constraintWidth + 0.00001) { | 947 | + if (_softWrap && |
948 | + offsetX + metrics.width > constraintWidth + 0.00001) { | ||
917 | if (spanCount > 0 && metrics.width <= constraintWidth) { | 949 | if (spanCount > 0 && metrics.width <= constraintWidth) { |
918 | overflow = true; | 950 | overflow = true; |
919 | lines.add(_Line( | 951 | lines.add(_Line( |
@@ -921,7 +953,9 @@ class RichText extends Widget with SpanningWidget { | @@ -921,7 +953,9 @@ class RichText extends Widget with SpanningWidget { | ||
921 | spanStart, | 953 | spanStart, |
922 | spanCount, | 954 | spanCount, |
923 | bottom, | 955 | bottom, |
924 | - offsetX - space.advanceWidth * style.wordSpacing! - style.letterSpacing!, | 956 | + offsetX - |
957 | + space.advanceWidth * style.wordSpacing! - | ||
958 | + style.letterSpacing!, | ||
925 | _textDirection, | 959 | _textDirection, |
926 | true, | 960 | true, |
927 | )); | 961 | )); |
@@ -983,7 +1017,9 @@ class RichText extends Widget with SpanningWidget { | @@ -983,7 +1017,9 @@ class RichText extends Widget with SpanningWidget { | ||
983 | ), | 1017 | ), |
984 | ); | 1018 | ); |
985 | 1019 | ||
986 | - offsetX += metrics.advanceWidth + space.advanceWidth * style.wordSpacing! + style.letterSpacing!; | 1020 | + offsetX += metrics.advanceWidth + |
1021 | + space.advanceWidth * style.wordSpacing! + | ||
1022 | + style.letterSpacing!; | ||
987 | } | 1023 | } |
988 | 1024 | ||
989 | if (line < spanLines.length - 1) { | 1025 | if (line < spanLines.length - 1) { |
@@ -992,7 +1028,9 @@ class RichText extends Widget with SpanningWidget { | @@ -992,7 +1028,9 @@ class RichText extends Widget with SpanningWidget { | ||
992 | spanStart, | 1028 | spanStart, |
993 | spanCount, | 1029 | spanCount, |
994 | bottom, | 1030 | bottom, |
995 | - offsetX - space.advanceWidth * style.wordSpacing! - style.letterSpacing!, | 1031 | + offsetX - |
1032 | + space.advanceWidth * style.wordSpacing! - | ||
1033 | + style.letterSpacing!, | ||
996 | _textDirection, | 1034 | _textDirection, |
997 | false, | 1035 | false, |
998 | )); | 1036 | )); |
@@ -1021,7 +1059,8 @@ class RichText extends Widget with SpanningWidget { | @@ -1021,7 +1059,8 @@ class RichText extends Widget with SpanningWidget { | ||
1021 | } | 1059 | } |
1022 | } | 1060 | } |
1023 | 1061 | ||
1024 | - offsetX -= space.advanceWidth * style.wordSpacing! - style.letterSpacing!; | 1062 | + offsetX -= |
1063 | + space.advanceWidth * style.wordSpacing! - style.letterSpacing!; | ||
1025 | } else if (span is WidgetSpan) { | 1064 | } else if (span is WidgetSpan) { |
1026 | span.child.layout( | 1065 | span.child.layout( |
1027 | context, | 1066 | context, |
@@ -1124,7 +1163,8 @@ class RichText extends Widget with SpanningWidget { | @@ -1124,7 +1163,8 @@ class RichText extends Widget with SpanningWidget { | ||
1124 | } | 1163 | } |
1125 | } | 1164 | } |
1126 | 1165 | ||
1127 | - box = PdfRect(0, 0, constraints.constrainWidth(width), constraints.constrainHeight(offsetY)); | 1166 | + box = PdfRect(0, 0, constraints.constrainWidth(width), |
1167 | + constraints.constrainHeight(offsetY)); | ||
1128 | 1168 | ||
1129 | _context | 1169 | _context |
1130 | ..endOffset = offsetY - _context.startOffset | 1170 | ..endOffset = offsetY - _context.startOffset |
@@ -1144,7 +1184,8 @@ class RichText extends Widget with SpanningWidget { | @@ -1144,7 +1184,8 @@ class RichText extends Widget with SpanningWidget { | ||
1144 | 1184 | ||
1145 | for (var index = 0; index < _decorations.length; index++) { | 1185 | for (var index = 0; index < _decorations.length; index++) { |
1146 | final decoration = _decorations[index]; | 1186 | final decoration = _decorations[index]; |
1147 | - if (decoration.startSpan >= _context.spanEnd || decoration.endSpan < _context.spanStart) { | 1187 | + if (decoration.startSpan >= _context.spanEnd || |
1188 | + decoration.endSpan < _context.spanStart) { | ||
1148 | _decorations.removeAt(index); | 1189 | _decorations.removeAt(index); |
1149 | index--; | 1190 | index--; |
1150 | } | 1191 | } |
@@ -1239,7 +1280,8 @@ class RichText extends Widget with SpanningWidget { | @@ -1239,7 +1280,8 @@ class RichText extends Widget with SpanningWidget { | ||
1239 | 1280 | ||
1240 | while (low + 1 < high) { | 1281 | while (low + 1 < high) { |
1241 | final metrics = font.stringMetrics(word.substring(0, pos), | 1282 | final metrics = font.stringMetrics(word.substring(0, pos), |
1242 | - letterSpacing: style.letterSpacing! / (style.fontSize! * textScaleFactor)) * | 1283 | + letterSpacing: |
1284 | + style.letterSpacing! / (style.fontSize! * textScaleFactor)) * | ||
1243 | (style.fontSize! * textScaleFactor); | 1285 | (style.fontSize! * textScaleFactor); |
1244 | 1286 | ||
1245 | if (metrics.width > maxWidth) { | 1287 | if (metrics.width > maxWidth) { |
@@ -46,8 +46,6 @@ void main() { | @@ -46,8 +46,6 @@ void main() { | ||
46 | pdf = Document(); | 46 | pdf = Document(); |
47 | }); | 47 | }); |
48 | 48 | ||
49 | - | ||
50 | - | ||
51 | test('RTL Text', () { | 49 | test('RTL Text', () { |
52 | pdf.addPage( | 50 | pdf.addPage( |
53 | Page( | 51 | Page( |
@@ -134,7 +132,9 @@ void main() { | @@ -134,7 +132,9 @@ void main() { | ||
134 | ); | 132 | ); |
135 | }); | 133 | }); |
136 | 134 | ||
137 | - test('Should render a blue box followed by a red box ordered RTL aligned right', () { | 135 | + test( |
136 | + 'Should render a blue box followed by a red box ordered RTL aligned right', | ||
137 | + () { | ||
138 | pdf.addPage( | 138 | pdf.addPage( |
139 | Page( | 139 | Page( |
140 | textDirection: TextDirection.rtl, | 140 | textDirection: TextDirection.rtl, |
@@ -149,7 +149,9 @@ void main() { | @@ -149,7 +149,9 @@ void main() { | ||
149 | ); | 149 | ); |
150 | }); | 150 | }); |
151 | 151 | ||
152 | - test('Should render a blue box followed by a red box ordered RTL with aligned center', () { | 152 | + test( |
153 | + 'Should render a blue box followed by a red box ordered RTL with aligned center', | ||
154 | + () { | ||
153 | pdf.addPage( | 155 | pdf.addPage( |
154 | Page( | 156 | Page( |
155 | textDirection: TextDirection.rtl, | 157 | textDirection: TextDirection.rtl, |
@@ -165,7 +167,9 @@ void main() { | @@ -165,7 +167,9 @@ void main() { | ||
165 | ); | 167 | ); |
166 | }); | 168 | }); |
167 | 169 | ||
168 | - test('Should render a blue box followed by a red box ordered RTL with CrossAxisAlignment.end aligned right', () { | 170 | + test( |
171 | + 'Should render a blue box followed by a red box ordered RTL with CrossAxisAlignment.end aligned right', | ||
172 | + () { | ||
169 | pdf.addPage( | 173 | pdf.addPage( |
170 | Page( | 174 | Page( |
171 | pageFormat: const PdfPageFormat(150, 100), | 175 | pageFormat: const PdfPageFormat(150, 100), |
@@ -184,7 +188,9 @@ void main() { | @@ -184,7 +188,9 @@ void main() { | ||
184 | ), | 188 | ), |
185 | ); | 189 | ); |
186 | }); | 190 | }); |
187 | - test('Should render a blue box followed by a red box ordered LTR aligned left', () { | 191 | + test( |
192 | + 'Should render a blue box followed by a red box ordered LTR aligned left', | ||
193 | + () { | ||
188 | pdf.addPage( | 194 | pdf.addPage( |
189 | Page( | 195 | Page( |
190 | pageFormat: const PdfPageFormat(150, 50), | 196 | pageFormat: const PdfPageFormat(150, 50), |
@@ -197,7 +203,9 @@ void main() { | @@ -197,7 +203,9 @@ void main() { | ||
197 | ), | 203 | ), |
198 | ); | 204 | ); |
199 | }); | 205 | }); |
200 | - test('Should render a blue box followed by a red box ordered TTB aligned right', () { | 206 | + test( |
207 | + 'Should render a blue box followed by a red box ordered TTB aligned right', | ||
208 | + () { | ||
201 | pdf.addPage( | 209 | pdf.addPage( |
202 | Page( | 210 | Page( |
203 | textDirection: TextDirection.rtl, | 211 | textDirection: TextDirection.rtl, |
@@ -216,7 +224,9 @@ void main() { | @@ -216,7 +224,9 @@ void main() { | ||
216 | ), | 224 | ), |
217 | ); | 225 | ); |
218 | }); | 226 | }); |
219 | - test('Should render a blue box followed by a red box ordered TTB aligned left', () { | 227 | + test( |
228 | + 'Should render a blue box followed by a red box ordered TTB aligned left', | ||
229 | + () { | ||
220 | pdf.addPage( | 230 | pdf.addPage( |
221 | Page( | 231 | Page( |
222 | textDirection: TextDirection.ltr, | 232 | textDirection: TextDirection.ltr, |
@@ -569,7 +579,11 @@ void main() { | @@ -569,7 +579,11 @@ void main() { | ||
569 | children: [ | 579 | children: [ |
570 | for (int i = 0; i < 7; i++) | 580 | for (int i = 0; i < 7; i++) |
571 | Container( | 581 | Container( |
572 | - color: [PdfColors.blue, PdfColors.red, PdfColors.yellow][i % 3], | 582 | + color: [ |
583 | + PdfColors.blue, | ||
584 | + PdfColors.red, | ||
585 | + PdfColors.yellow | ||
586 | + ][i % 3], | ||
573 | ), | 587 | ), |
574 | ], | 588 | ], |
575 | ), | 589 | ), |
@@ -594,7 +608,11 @@ void main() { | @@ -594,7 +608,11 @@ void main() { | ||
594 | children: [ | 608 | children: [ |
595 | for (int i = 0; i < 7; i++) | 609 | for (int i = 0; i < 7; i++) |
596 | Container( | 610 | Container( |
597 | - color: [PdfColors.blue, PdfColors.red, PdfColors.yellow][i % 3], | 611 | + color: [ |
612 | + PdfColors.blue, | ||
613 | + PdfColors.red, | ||
614 | + PdfColors.yellow | ||
615 | + ][i % 3], | ||
598 | ), | 616 | ), |
599 | ], | 617 | ], |
600 | ), | 618 | ), |
@@ -618,7 +636,11 @@ void main() { | @@ -618,7 +636,11 @@ void main() { | ||
618 | children: [ | 636 | children: [ |
619 | for (int i = 0; i < 7; i++) | 637 | for (int i = 0; i < 7; i++) |
620 | Container( | 638 | Container( |
621 | - color: [PdfColors.blue, PdfColors.red, PdfColors.yellow][i % 3], | 639 | + color: [ |
640 | + PdfColors.blue, | ||
641 | + PdfColors.red, | ||
642 | + PdfColors.yellow | ||
643 | + ][i % 3], | ||
622 | ), | 644 | ), |
623 | ], | 645 | ], |
624 | ), | 646 | ), |
@@ -643,7 +665,11 @@ void main() { | @@ -643,7 +665,11 @@ void main() { | ||
643 | children: [ | 665 | children: [ |
644 | for (int i = 0; i < 7; i++) | 666 | for (int i = 0; i < 7; i++) |
645 | Container( | 667 | Container( |
646 | - color: [PdfColors.blue, PdfColors.red, PdfColors.yellow][i % 3], | 668 | + color: [ |
669 | + PdfColors.blue, | ||
670 | + PdfColors.red, | ||
671 | + PdfColors.yellow | ||
672 | + ][i % 3], | ||
647 | ), | 673 | ), |
648 | ], | 674 | ], |
649 | ), | 675 | ), |
test/golden/rtl-layout.pdf
0 → 100644
No preview for this file type
No preview for this file type
-
Please register or login to post a comment