自定义颤振工具提示 [英] Customising flutter Tooltip

查看:33
本文介绍了自定义颤振工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法自定义 Flutter 工具提示以更改颜色并增加填充/边距.默认值似乎填满了整个屏幕的宽度,并且没有命名参数来进一步配置它.下面的代码会生成一个 Tooltip,如屏幕截图所示.

Tooltip(child: IconButton(icon: Icon(Icons.info, size: 30.0)),消息:'Lorem ipsum dolor sit amet,consectetur''adipiscing elit,sed do eiusmod tempor incidudunt''ut labore et dolore magna aliqua.''Ut enim ad minim veniam, quis nostrud exercitation''ullamco laboris nisi ut aliquip ex ea commodo consequat',填充:EdgeInsets.all(20),preferBelow: 真的,垂直偏移:20,)

我至少尝试将其从屏幕边缘移开并以更紧凑的方式显示.显然,在 Padding 中包装 Tooltip 只会影响子小部件(IconButton)的定位,而不是 Tooltip本身.

理想情况下,我希望显示与以下格式类似的工具提示.超级理想的是,我希望它通过单击而不是长按来显示.我猜 Tooltip 不一定是我应该使用的小部件?

解决方案

要自定义您的工具提示,您可以查看

Is there a way to customise the Flutter tooltip to change colour and increase the padding/margins. The default seems to fill the width of the whole screen and there are no named parameters to configure this any further. The code below produces a Tooltip as shown in the screenshot.

Tooltip(child:  IconButton(icon: Icon(Icons.info, size: 30.0)),
        message: 'Lorem ipsum dolor sit amet, consectetur '
                 'adipiscing elit, sed do eiusmod tempor incididunt '
                 'ut labore et dolore magna aliqua. '
                 'Ut enim ad minim veniam, quis nostrud exercitation '
                 'ullamco laboris nisi ut aliquip ex ea commodo consequat',
        padding: EdgeInsets.all(20),
        preferBelow: true,
        verticalOffset: 20,
        )

I'm trying at the very least to pad it away from the edge of the screen and display it in a more compact manner. Obviously wrapping the Tooltip in Padding just affects the positioning of the child widget (the IconButton) rather than the Tooltip itself.

Ideally I'm looking to display a tooltip something with a similar format to the one below. And super-ideally I'd like it to be displayed with a single tap rather than a long press. I'm guessing Tooltip isn't necessarily the widget I should be using?

解决方案

To customize your tooltip you can take a look here. Or it's example here.

这篇关于自定义颤振工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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