如何在Flutter中添加不太底部的应用栏

时间:2020-09-26 16:35:50

标签: flutter

我在将应用程序栏和底部应用程序栏置于颤动时遇到问题。 我创建一个脚手架,并使用应用程序栏和bottomNavigationBar属性。我分别使用AppBar和BottomAppBar。但是当我运行它时,只会显示底部的应用程序栏,而不显示顶部的应用程序栏。我究竟做错了什么?甚至可能同时拥有底部应用程序栏和顶部应用程序栏?

1 个答案:

答案 0 :(得分:0)

它应该可以工作,也许BottomAppBar的子对象没有高度,这里是一个有效的示例:

 return Scaffold(
  appBar: AppBar(
    title: Text('Title'),
  ),
  body: Center(child: Text('Center')),
  bottomNavigationBar: BottomAppBar(
    color: Colors.red,
    child: Container(
      height: 100,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: [
          Icon(Icons.home),
          Icon(Icons.pause_circle_filled),
          Icon(Icons.settings)
        ],
      ),
    ),
  ),
);