繁体   English   中英

如何在颤动的BottomAppBar中的图标正下方制作文本?

[英]How to make a text right below an icon in BottomAppBar in flutter?

所以我有一个 BottomAppBar 并且我试图在图标按钮下方有一个文本,我尝试使用 Column 将 mainaxissize 设置为 min 并且我也尝试使用我可以做的最小间距的 wrap 但这些方法都没有将文本放在图标正下方,图标和我要删除的文本之间似乎存在某种类型的间隙或填充,我怎样才能使图标正下方的文本?

这是代码:

bottomNavigationBar: BottomAppBar(
    shape: CircularNotchedRectangle(),
    notchMargin: 4.0,
    child: new Row(
      // mainAxisSize: MainAxisSize.max,
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      children: <Widget>[
        Wrap(
          direction: Axis.vertical,
            children: [
          IconButton(
              icon: Icon(
                Icons.home_outlined,
                color: Colors.grey,
              ),
              onPressed: () => screenIndex(0)),
          Text("Home")
        ]),
        IconButton(
            icon: Icon(
              Icons.history,
              color: Colors.grey,
            ),
            onPressed: () => screenIndex(1)),
        SizedBox(width: 10),
        IconButton(
            icon: Icon(
              Icons.message,
              color: Colors.grey,
            ),
            onPressed: () => screenIndex(3)),
        IconButton(
            icon: Icon(
              Icons.person_outline,
              color: Colors.grey,
            ),
            onPressed: () => screenIndex(4)),
      ],
    ),
  ),

这是它目前显示的内容:

在此处输入图像描述

我想把文字放在图标下面

iconbutton 有一个默认的填充。 您可以使用图标并用墨水瓶或手势检测器将其包裹起来,如下所示

InkWell(
onTap: () => screenIndex(0),
Column(
 mainAxisSize: MainAxisSize.min,
  children:[
     Icon(Icons.home_outlined, color: Colors.grey),
     Text("Home")
  ]
 )
)

更改 IconButton 小部件如下

 Wrap(
              crossAxisAlignment: WrapCrossAlignment.center,
                direction: Axis.vertical,
                children: [
                  IconButton(
                      icon: Icon(
                        Icons.home_outlined,
                        color: Colors.grey,
                      ),
                      padding: EdgeInsets.zero,
                      constraints: BoxConstraints(),
                      onPressed: () => screenIndex(0)),
                  Text("Home")
                ]),

在此处输入图像描述

暂无
暂无

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

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