Showing
4 changed files
with
25 additions
and
13 deletions
@@ -582,22 +582,15 @@ class Expanded extends Flexible { | @@ -582,22 +582,15 @@ class Expanded extends Flexible { | ||
582 | 582 | ||
583 | /// Spacer creates an adjustable, empty spacer that can be used to tune the | 583 | /// Spacer creates an adjustable, empty spacer that can be used to tune the |
584 | /// spacing between widgets in a [Flex] container, like [Row] or [Column]. | 584 | /// spacing between widgets in a [Flex] container, like [Row] or [Column]. |
585 | -class Spacer extends StatelessWidget { | ||
586 | - Spacer({this.flex = 1}) | 585 | +class Spacer extends Flexible { |
586 | + Spacer({int flex = 1}) | ||
587 | : assert(flex != null), | 587 | : assert(flex != null), |
588 | assert(flex > 0), | 588 | assert(flex > 0), |
589 | - super(); | ||
590 | - | ||
591 | - /// The flex factor to use in determining how much space to take up. | ||
592 | - final int flex; | ||
593 | - | ||
594 | - @override | ||
595 | - Widget build(Context context) { | ||
596 | - return Expanded( | 589 | + super( |
597 | flex: flex, | 590 | flex: flex, |
591 | + fit: FlexFit.tight, | ||
598 | child: SizedBox.shrink(), | 592 | child: SizedBox.shrink(), |
599 | ); | 593 | ); |
600 | - } | ||
601 | } | 594 | } |
602 | 595 | ||
603 | typedef IndexedWidgetBuilder = Widget Function(Context context, int index); | 596 | typedef IndexedWidgetBuilder = Widget Function(Context context, int index); |
@@ -75,6 +75,24 @@ void main() { | @@ -75,6 +75,24 @@ void main() { | ||
75 | ); | 75 | ); |
76 | }); | 76 | }); |
77 | 77 | ||
78 | + test('Flex Widgets Spacer', () { | ||
79 | + pdf.addPage( | ||
80 | + Page( | ||
81 | + build: (Context context) => Column( | ||
82 | + children: <Widget>[ | ||
83 | + Text('Begin'), | ||
84 | + Spacer(), // Defaults to a flex of one. | ||
85 | + Text('Middle'), | ||
86 | + // Gives twice the space between Middle and End than Begin and Middle. | ||
87 | + Spacer(flex: 2), | ||
88 | + // Expanded(flex: 2, child: SizedBox.shrink()), | ||
89 | + Text('End'), | ||
90 | + ], | ||
91 | + ), | ||
92 | + ), | ||
93 | + ); | ||
94 | + }); | ||
95 | + | ||
78 | tearDownAll(() { | 96 | tearDownAll(() { |
79 | final File file = File('widgets-flex.pdf'); | 97 | final File file = File('widgets-flex.pdf'); |
80 | file.writeAsBytesSync(pdf.save()); | 98 | file.writeAsBytesSync(pdf.save()); |
No preview for this file type
-
Please register or login to post a comment