mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fix SafeArea and SliverSafeArea debug flag properties (#63455)
This commit is contained in:
parent
5ec7426be7
commit
03dcd1bd5a
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user