Showing
2 changed files
with
37 additions
and
0 deletions
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | * Add jpeg image loading function | 2 | * Add jpeg image loading function |
3 | * Add Theme::copyFrom() method | 3 | * Add Theme::copyFrom() method |
4 | * Allow Annotations in TextSpan | 4 | * Allow Annotations in TextSpan |
5 | +* Add SizedBox Widget | ||
5 | 6 | ||
6 | # 1.3.7 | 7 | # 1.3.7 |
7 | * Add Pdf Creation date | 8 | * Add Pdf Creation date |
@@ -470,3 +470,39 @@ class CustomPaint extends SingleChildWidget { | @@ -470,3 +470,39 @@ class CustomPaint extends SingleChildWidget { | ||
470 | context.canvas.restoreContext(); | 470 | context.canvas.restoreContext(); |
471 | } | 471 | } |
472 | } | 472 | } |
473 | + | ||
474 | +/// A box with a specified size. | ||
475 | +class SizedBox extends StatelessWidget { | ||
476 | + /// Creates a fixed size box. | ||
477 | + SizedBox({this.width, this.height, this.child}); | ||
478 | + | ||
479 | + /// Creates a box that will become as large as its parent allows. | ||
480 | + SizedBox.expand({this.child}) | ||
481 | + : width = double.infinity, | ||
482 | + height = double.infinity; | ||
483 | + | ||
484 | + /// Creates a box that will become as small as its parent allows. | ||
485 | + SizedBox.shrink({this.child}) | ||
486 | + : width = 0.0, | ||
487 | + height = 0.0; | ||
488 | + | ||
489 | + /// Creates a box with the specified size. | ||
490 | + SizedBox.fromSize({this.child, PdfPoint size}) | ||
491 | + : width = size?.x, | ||
492 | + height = size?.y; | ||
493 | + | ||
494 | + /// If non-null, requires the child to have exactly this width. | ||
495 | + final double width; | ||
496 | + | ||
497 | + /// If non-null, requires the child to have exactly this height. | ||
498 | + final double height; | ||
499 | + | ||
500 | + final Widget child; | ||
501 | + | ||
502 | + @override | ||
503 | + Widget build(Context context) { | ||
504 | + return ConstrainedBox( | ||
505 | + child: child, | ||
506 | + constraints: BoxConstraints.tightFor(width: width, height: height)); | ||
507 | + } | ||
508 | +} |
-
Please register or login to post a comment