简体   繁体   English

在 appbar 操作中的图标按钮下方添加文本?

[英]Add text underneath iconbutton in appbar actions?

I'm currently trying to add the text ('Filter'), underneath an icon inside of the actions field within an AppBar.我目前正在尝试在 AppBar 中的操作字段内的图标下方添加文本(“过滤器”)。

Without any text being added underneath it.没有在它下面添加任何文本。 the action aligned exactly with the text and hamburger menu icon动作与文本和汉堡菜单图标完全一致

Example:例子: 在此处输入图像描述

There are two issues I'm having:我有两个问题:

  1. When I add text, the filter icon moves up a little, I want the icon to be the same spot but text added understand.当我添加文本时,过滤器图标会向上移动一点,我希望图标在同一个位置,但添加的文本可以理解。
  2. I'm getting an overflow issue我遇到了溢出问题

在此处输入图像描述

How can I fix this?我怎样才能解决这个问题?

Thanks!谢谢!

    _appbarActions = [
      Column(
        children: [
          IconButton(icon: const Icon(Icons.filter_alt_outlined), onPressed: () {}),
          Text('Filter'),
        ],
      )
    ];

Try the below snippet code:试试下面的代码片段:

  1. To remove the space between IconButton and Text use Icon only;要删除IconButtonText之间的空格,请仅使用Icon
  2. For the overflow error you can manage the icon size with text fontSize (styles);对于溢出错误,您可以使用文本 fontSize (styles) 管理图标大小;
  3. For events wrap the column by InkWell widget对于事件,使用InkWell小部件包装列

Container(
        margin: const EdgeInsets.only(right: 8.0),
        child: InkWell(
          onTap: () {},
          child: Stack(
            children: [
              Center(
                child: Icon(Icons.filter_alt_outlined),
              ),
              Positioned(
                child: Text(
                  'Filter',
                  style: TextStyle(fontSize: 10.0),
                ),
                bottom: 5,
              ),
            ],
          ),
        ),
      )

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM