Unverified Commit 7736b9ee authored by BambinoUA's avatar BambinoUA Committed by GitHub

Don't display empty tooltips (Tooltips with empty `message` property) (#87638)

parent 77c27059
......@@ -475,6 +475,12 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
@override
Widget build(BuildContext context) {
// If message is empty then no need to create a tooltip overlay to show
// the empty black container so just return the wrapped child as is or
// empty container if child is not specified.
if (widget.message.isEmpty) {
return widget.child ?? const SizedBox();
}
assert(Overlay.of(context, debugRequiredFor: widget) != null);
final ThemeData theme = Theme.of(context);
final TooltipThemeData tooltipTheme = TooltipTheme.of(context);
......
......@@ -1497,6 +1497,32 @@ void main() {
await testGestureLongPress(tester, tooltip);
expect(find.text(tooltipText), findsNothing);
});
testWidgets('Tooltip should not be shown with empty message (with child)', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Tooltip(
message: tooltipText,
child: Text(tooltipText),
),
),
);
expect(find.text(tooltipText), findsOneWidget);
});
testWidgets('Tooltip should not be shown with empty message (without child)', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Tooltip(
message: tooltipText,
),
),
);
expect(find.text(tooltipText), findsNothing);
if (tooltipText.isEmpty) {
expect(find.byType(SizedBox), findsOneWidget);
}
});
}
Future<void> setWidgetForTooltipMode(WidgetTester tester, TooltipTriggerMode triggerMode) async {
......
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