Unverified Commit 03dcd1bd authored by Declan Woods's avatar Declan Woods Committed by GitHub

Fix SafeArea and SliverSafeArea debug flag properties (#63455)

parent 5ec7426b
......@@ -125,9 +125,9 @@ class SafeArea extends StatelessWidget {
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(FlagProperty('left', value: left, ifTrue: 'avoid left padding'));
properties.add(FlagProperty('top', value: left, ifTrue: 'avoid top padding'));
properties.add(FlagProperty('right', value: left, ifTrue: 'avoid right padding'));
properties.add(FlagProperty('bottom', value: left, ifTrue: 'avoid bottom padding'));
properties.add(FlagProperty('top', value: top, ifTrue: 'avoid top padding'));
properties.add(FlagProperty('right', value: right, ifTrue: 'avoid right padding'));
properties.add(FlagProperty('bottom', value: bottom, ifTrue: 'avoid bottom padding'));
}
}
......@@ -219,8 +219,8 @@ class SliverSafeArea extends StatelessWidget {
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(FlagProperty('left', value: left, ifTrue: 'avoid left padding'));
properties.add(FlagProperty('top', value: left, ifTrue: 'avoid top padding'));
properties.add(FlagProperty('right', value: left, ifTrue: 'avoid right padding'));
properties.add(FlagProperty('bottom', value: left, ifTrue: 'avoid bottom padding'));
properties.add(FlagProperty('top', value: top, ifTrue: 'avoid top padding'));
properties.add(FlagProperty('right', value: right, ifTrue: 'avoid right padding'));
properties.add(FlagProperty('bottom', value: bottom, ifTrue: 'avoid bottom padding'));
}
}
......@@ -89,6 +89,22 @@ void main() {
expect(tester.getBottomRight(find.byType(Placeholder)), const Offset(800.0, 600.0));
});
testWidgets('SafeArea - properties', (WidgetTester tester) async {
final SafeArea child = SafeArea(
left: true,
right: false,
bottom: false,
child: Container()
);
final DiagnosticPropertiesBuilder properties = DiagnosticPropertiesBuilder();
child.debugFillProperties(properties);
expect(properties.properties.any((DiagnosticsNode n) => n is FlagProperty && n.toString() == 'avoid left padding'), true);
expect(properties.properties.any((DiagnosticsNode n) => n is FlagProperty && n.toString() == 'avoid right padding'), false);
expect(properties.properties.any((DiagnosticsNode n) => n is FlagProperty && n.toString() == 'avoid top padding'), true);
expect(properties.properties.any((DiagnosticsNode n) => n is FlagProperty && n.toString() == 'avoid bottom padding'), false);
});
group('SafeArea maintains bottom viewPadding when specified for consumed bottom padding', () {
Widget boilerplate(Widget child) {
return Localizations(
......@@ -300,4 +316,20 @@ void main() {
]);
});
});
testWidgets('SliverSafeArea - properties', (WidgetTester tester) async {
const SliverSafeArea child = SliverSafeArea(
left: true,
right: false,
bottom: false,
sliver: SliverToBoxAdapter(child: SizedBox(width: 800.0, height: 100.0, child: Text('padded'))),
);
final DiagnosticPropertiesBuilder properties = DiagnosticPropertiesBuilder();
child.debugFillProperties(properties);
expect(properties.properties.any((DiagnosticsNode n) => n is FlagProperty && n.toString() == 'avoid left padding'), true);
expect(properties.properties.any((DiagnosticsNode n) => n is FlagProperty && n.toString() == 'avoid right padding'), false);
expect(properties.properties.any((DiagnosticsNode n) => n is FlagProperty && n.toString() == 'avoid top padding'), true);
expect(properties.properties.any((DiagnosticsNode n) => n is FlagProperty && n.toString() == 'avoid bottom padding'), false);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment