33

Is there a way to set a tooltip on a Text widget:

new Text(
    "Some content",
    tooltip: "Displays a message to you"
  )

This does not work. However it does work, as mentioned here, on things like the FloatingActionButton:

new FloatingActionButton(
    onPressed: action,
    tooltip: "Action",
    child: new Icon(Icons.add),
  )

I understand that the Text class does simply not have tooltip implemented. I want to know if there is a way to do it anyway.

creativecreatorormaybenot
  • 114,516
  • 58
  • 291
  • 402

3 Answers3

94

You can wrap your text into a Tooltip widget.

Tooltip(message: "Hello World", child: new Text("foo"));
creativecreatorormaybenot
  • 114,516
  • 58
  • 291
  • 402
Rémi Rousselet
  • 256,336
  • 79
  • 519
  • 432
1

Tooltip(message: "This is the tooltip message", child: new Text("Show tooltip"));

You can also provide a height, decoration and other parameters.

1

Yes, there is a way to do that. Wrap your Text Widget inside a flutter Tooltip Widget as mentioned above But it is triggered on the long press by default if you want it be triggered on a single tap You can its triggerMode property.

Talha
  • 23
  • 6