BottomNavigationBar透明背景

问题描述 投票:0回答:1

我正在尝试构建一个没有背景(透明)的BottomNavigationBar,到目前为止这是我所做的,但我仍然有阴影,也应该删除:

return Scaffold(
  body: body,
  bottomNavigationBar: Theme(
    data: Theme.of(context).copyWith(
        canvasColor: Colors.transparent,
        primaryColor: Colors.white,
        textTheme: Theme
            .of(context)
            .textTheme
            .copyWith(caption: TextStyle(color: Colors.deepOrange))),
    child: BottomNavigationBar(
      type: BottomNavigationBarType.fixed,
      currentIndex: 0,
      items: [
        BottomNavigationBarItem(
          icon: Icon(Icons.home),
          title: Text("Home"),
        ),
        BottomNavigationBarItem(
          icon: Icon(Icons.map),
          title: Text("Map"),
        )
      ],
    ),
  ),
);
dart flutter
1个回答
1
投票

我认为如果你使用透明背景,那么图标将不是很清楚,或者你可以像这样使用你的自定义小部件。这可能对你有所帮助。

return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: new Container(
        child: new Stack(children: <Widget>[
          new Container(
            color: Colors.lightGreen,
            child: new Center(
              child: new Text('Hello'),
            ),
          ),
          new Align(alignment: Alignment.bottomCenter,child: new Container(
            height: 100.0,
            child: new Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
              new Icon(Icons.home),
                new Icon(Icons.map)
            ],),
          ),)
        ],),
      ),
    );
© www.soinside.com 2019 - 2024. All rights reserved.