creativecreatorormaybenot
creativecreatorormaybenot

Reputation: 126664

Flutter Tooltip on all widgets

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.

Upvotes: 38

Views: 47965

Answers (3)

Talha
Talha

Reputation: 33

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 long press by default. If you want it to be triggered on a single tap, you can specify its triggerMode property.

Upvotes: 2

Rémi Rousselet
Rémi Rousselet

Reputation: 276957

You can wrap your text into a Tooltip widget.

Tooltip(message: "Hello World", child: new Text("foo"));

Upvotes: 106

Asamoah Michael
Asamoah Michael

Reputation: 11

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

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

Upvotes: 1

Related Questions