David PHAM-VAN

Fix Spacer Widget

... ... @@ -7,6 +7,7 @@
- Fix PdfColors.fromHex()
- Update Barcode library to 1.9.0
- Fix exif orientation crash
- Fix Spacer Widget
## 1.7.1
... ...
... ... @@ -582,22 +582,15 @@ class Expanded extends Flexible {
/// Spacer creates an adjustable, empty spacer that can be used to tune the
/// spacing between widgets in a [Flex] container, like [Row] or [Column].
class Spacer extends StatelessWidget {
Spacer({this.flex = 1})
class Spacer extends Flexible {
Spacer({int flex = 1})
: assert(flex != null),
assert(flex > 0),
super();
/// The flex factor to use in determining how much space to take up.
final int flex;
@override
Widget build(Context context) {
return Expanded(
super(
flex: flex,
fit: FlexFit.tight,
child: SizedBox.shrink(),
);
}
}
typedef IndexedWidgetBuilder = Widget Function(Context context, int index);
... ...
... ... @@ -75,6 +75,24 @@ void main() {
);
});
test('Flex Widgets Spacer', () {
pdf.addPage(
Page(
build: (Context context) => Column(
children: <Widget>[
Text('Begin'),
Spacer(), // Defaults to a flex of one.
Text('Middle'),
// Gives twice the space between Middle and End than Begin and Middle.
Spacer(flex: 2),
// Expanded(flex: 2, child: SizedBox.shrink()),
Text('End'),
],
),
),
);
});
tearDownAll(() {
final File file = File('widgets-flex.pdf');
file.writeAsBytesSync(pdf.save());
... ...