代码之家  ›  专栏  ›  技术社区  ›  LaurenTsai

如何在Flatter中的BottomAppBar中的图标下方创建文本?

  •  0
  • LaurenTsai  · 技术社区  · 1 年前

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

    这是它当前显示的内容:

    enter image description here

    我想把文字放在图标的正下方

    2 回复  |  直到 1 年前
        1
  •  0
  •   Jungwon    1 年前

    按如下所示更改图标按钮小部件

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

    enter image description here

        2
  •  0
  •   Kaushik Chandru    1 年前

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