Skip to content

Commit 4b67827

Browse files
authored
Add Tooltip default vertical padding (#103395)
1 parent 384800b commit 4b67827

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

packages/flutter/lib/src/material/tooltip.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ class Tooltip extends StatefulWidget {
134134

135135
/// The amount of space by which to inset the tooltip's [child].
136136
///
137-
/// Defaults to 16.0 logical pixels in each direction.
137+
/// On mobile, defaults to 16.0 logical pixels horizontally and 4.0 vertically.
138+
/// On desktop, defaults to 8.0 logical pixels horizontally and 4.0 vertically.
138139
final EdgeInsetsGeometry? padding;
139140

140141
/// The empty space that surrounds the tooltip.
@@ -403,11 +404,11 @@ class TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
403404
case TargetPlatform.macOS:
404405
case TargetPlatform.linux:
405406
case TargetPlatform.windows:
406-
return const EdgeInsets.symmetric(horizontal: 8.0);
407+
return const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0);
407408
case TargetPlatform.android:
408409
case TargetPlatform.fuchsia:
409410
case TargetPlatform.iOS:
410-
return const EdgeInsets.symmetric(horizontal: 16.0);
411+
return const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0);
411412
}
412413
}
413414

packages/flutter/test/material/tooltip_test.dart

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -801,15 +801,16 @@ void main() {
801801
tooltipKey.currentState?.ensureTooltipVisible();
802802
await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0)
803803

804-
final RenderBox tip = tester.renderObject(
805-
_findTooltipContainer(tooltipText),
806-
);
804+
final RenderBox tip = tester.renderObject(_findTooltipContainer(tooltipText));
807805
expect(tip.size.height, equals(32.0));
808806
expect(tip.size.width, equals(74.0));
809807
expect(tip, paints..rrect(
810808
rrect: RRect.fromRectAndRadius(tip.paintBounds, const Radius.circular(4.0)),
811809
color: const Color(0xe6616161),
812810
));
811+
812+
final Container tooltipContainer = tester.firstWidget<Container>(_findTooltipContainer(tooltipText));
813+
expect(tooltipContainer.padding, const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0));
813814
});
814815

815816
testWidgets('Tooltip default size, shape, and color test for Desktop', (WidgetTester tester) async {
@@ -830,14 +831,15 @@ void main() {
830831
final RenderParagraph tooltipRenderParagraph = tester.renderObject<RenderParagraph>(find.text(tooltipText));
831832
expect(tooltipRenderParagraph.textSize.height, equals(12.0));
832833

833-
final RenderBox tooltipContainer = tester.renderObject(
834-
_findTooltipContainer(tooltipText),
835-
);
836-
expect(tooltipContainer.size.height, equals(24.0));
837-
expect(tooltipContainer, paints..rrect(
838-
rrect: RRect.fromRectAndRadius(tooltipContainer.paintBounds, const Radius.circular(4.0)),
834+
final RenderBox tooltipRenderBox = tester.renderObject(_findTooltipContainer(tooltipText));
835+
expect(tooltipRenderBox.size.height, equals(24.0));
836+
expect(tooltipRenderBox, paints..rrect(
837+
rrect: RRect.fromRectAndRadius(tooltipRenderBox.paintBounds, const Radius.circular(4.0)),
839838
color: const Color(0xe6616161),
840839
));
840+
841+
final Container tooltipContainer = tester.firstWidget<Container>(_findTooltipContainer(tooltipText));
842+
expect(tooltipContainer.padding, const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0));
841843
}, variant: const TargetPlatformVariant(<TargetPlatform>{TargetPlatform.macOS, TargetPlatform.linux, TargetPlatform.windows}));
842844

843845
testWidgets('Can tooltip decoration be customized', (WidgetTester tester) async {
@@ -1437,7 +1439,7 @@ void main() {
14371439
tip = tester.renderObject(
14381440
_findTooltipContainer(tooltipText),
14391441
);
1440-
expect(tip.size.height, equals(56.0));
1442+
expect(tip.size.height, equals(64.0));
14411443
});
14421444

14431445
testWidgets('Tooltip text displays with richMessage', (WidgetTester tester) async {

0 commit comments

Comments
 (0)