Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tooltip message text and background color

I have Image.asset wrapped on Tooltip

Padding(
     padding: edgeInsets,
     child: Tooltip(preferBelow: false, message: "Miejsca parkingowe ogólnodostępne", child: Image.asset("assets/icons/garage.png", width: _iconSize, height: _iconSize,)),
),

How to set tooltip message text color and background color?

like image 708
Maciek Avatar asked Dec 13 '25 01:12

Maciek


2 Answers

You can change color of tootip with textStyle attribute. and background color of tooltip with decoration attribute.

    Padding(
         padding: edgeInsets,
         child: Tooltip(textStyle: TextStyle(color: Colors.white),decoration: BoxDecoration(color: Colors.red),text preferBelow: false, message: "Miejsca parkingowe ogólnodostępne", 
         child: Image.asset("assets/icons/garage.png", width: _iconSize, height: _iconSize,)),
     ),

like image 177
AliAzad Avatar answered Dec 15 '25 18:12

AliAzad


ToolTip supports the decoration named argument, so you don't need to change your top-level theme.

/// Specifies the tooltip's shape and background color.
///
/// If not specified, defaults to a rounded rectangle with a border radius of
/// 4.0, and a color derived from the [ThemeData.textTheme] if the
/// [ThemeData.brightness] is dark, and [ThemeData.primaryTextTheme] if not.
final Decoration decoration;

However, there are other widgets, that include the ToolTip widget in their build method, for example, IconButton where they only support a tooltip as a String, so there's no way currently to change the tooltip style for the IconButton

like image 26
Vince Varga Avatar answered Dec 15 '25 18:12

Vince Varga



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!