【问题标题】:I am using flutter bottomNavigatonBar widget, Is there anything which it can be raised?我正在使用颤振的底部导航栏小部件,有什么可以提高的吗?
【发布时间】:2020-06-03 12:15:59
【问题描述】:

This is what I want !

        floatingActionButton: FloatingActionButton(
          onPressed: () {},
          child: Icon(Icons.add),
        ),
        bottomNavigationBar: BottomAppBar(
          shape: CircularNotchedRectangle(),
          notchMargin: 4.0,
          child: Row(
            mainAxisSize: MainAxisSize.max,
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              IconButton(
                icon: Icon(Icons.home),
                onPressed: () {},
              ),
              IconButton(
                icon: Icon(Icons.search),
                onPressed: () {},
              ),
              IconButton(
                icon: Icon(Icons.notifications),
                onPressed: () {},
              ),
              IconButton(
                icon: Icon(Icons.perm_identity),
                onPressed: () {},
              ),
            ],
          ),
        ),

我希望导航栏从底部略微升高并具有圆形边框。目前它位于屏幕底部。

【问题讨论】:

标签: android flutter flutter-layout flutter-animation


【解决方案1】:

这就是你想要的。但是,我建议您不要使用IconButton,而是使用FlatButton,因为它们使用起来更简单,并且据我所知,IconButton 的宽度和高度不能被覆盖,所以当您按下 IconButton 并使用包裹的容器时它,它看起来会很不正常。

但是对于您的解决方案,请使用容器包装您的 IconButton 并使用 decoration 属性添加阴影并提供凸起效果。


    Container(
      width: 100,
      decoration : BoxDecoration(
        borderRadius: BorderRadius.circular(30),
        color: Colors.red,
        boxShadow: [
          BoxShadow(color: Colors.black, blurRadius: 2, offset: Offset(5,5))

        ]

      ),
      child: IconButton(
        color: Colors.green,
        icon : Icon(Icons.access_alarm),
        onPressed : (){
          //
        }
      ),
    )

这是输出:

您可以更改offset 属性来调整阴影的方向。

【讨论】:

    【解决方案2】:

    您可以使用Fancy Navigation bar,如果您想要该输出,您可以通过在其标题中放置一个空文本来删除该文本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-27
      • 1970-01-01
      • 1970-01-01
      • 2022-01-03
      • 2021-08-07
      • 2021-10-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多