所有小部件上的Flutter Tooltip [英] Flutter Tooltip on all widgets

查看:320
本文介绍了所有小部件上的Flutter Tooltip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在文本小部件上设置工具提示

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

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

这不起作用。但是它确实可以正常工作,例如此处所述,例如 FloatingActionButton

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),
  )

我了解到 Text 类根本没有实现 tooltip 。我想知道是否有办法。

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.

推荐答案

您可以将文本包装到 Tooltip 小部件。

You can wrap your text into a Tooltip widget.

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

这篇关于所有小部件上的Flutter Tooltip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆