如何创建自定义半底导航布局

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

我正在尝试为底部导航栏创建自定义UI。任何人都知道如何做这样的事情。

示例:仅在蓝色的一半中显示导航按钮,而将黄色部分留空。

example UI

flutter dart navigation navigationbar selected
1个回答
0
投票
  bottomNavigationBar:Stack(
    children: <Widget>[
      Container(width: 150,height: 60,color: Colors.yellowAccent,),
      Theme(
        data: Theme.of(context).copyWith(canvasColor: Colors.transparent),
        child:Row(
          children: <Widget>[
            Container(width: 0.4*MediaQuery.of(context).size.width,height: 60,),
            **Container(constraints: BoxConstraints(maxWidth: 0.6*MediaQuery.of(context).size.width),
              child: BottomNavigationBar(**
                elevation: 0,
                currentIndex: index,
                onTap: changeIndex,
                selectedItemColor: Colors.deepOrange,
                type: BottomNavigationBarType.fixed,
                items: [
                  BottomNavigationBarItem(
                    backgroundColor: Color.fromRGBO(0, 0, 0, 0),
                    icon: Padding(
                      padding: const EdgeInsets.only(top: 4),
                      child: Container(
                        width: 30,
                        child: Container(
                          height: 30,
                          width: 30,
                          child: Icon(Icons.access_alarm),
                        ),
                      ),
                    ),
                    title: Text(
                      '',
                      style: TextStyle(
                        fontSize: 0,
                      ),
                    ),
                  ),
                  BottomNavigationBarItem(
                    icon: Padding(
                      padding: const EdgeInsets.only(top: 4),
                      child: Container(
                        width: 30,
                        child: Container(
                          height: 30,
                          width: 30,
                          child: Icon(Icons.access_alarm),
                        ),
                      ),
                    ),
                    title: Text(
                      '',
                      style: TextStyle(
                        fontSize: 0,
                      ),
                    ),
                  ),
                  BottomNavigationBarItem(
                    icon: Padding(
                      padding: const EdgeInsets.only(top: 4),
                      child: Container(
                        width: 30,
                        child: Container(
                          height: 30,
                          width: 30,
                          child: Icon(Icons.access_alarm),
                        ),
                      ),
                    ),
                    title: Text(
                      '',
                      style: TextStyle(
                        fontSize: 0,
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    ],
  ),
© www.soinside.com 2019 - 2024. All rights reserved.