简体   繁体   English

如何在颤动中夹住标签栏容器的边缘?

[英]How do I clip the edges of my tab bar container in flutter?

I have a container at the bottom of my screen that has a BottomNavigationBar.我的屏幕底部有一个容器,它有一个 BottomNavigationBar。 I want the container to get the colour of my background.我希望容器获得我的背景颜色。 Even after adding CLipRRect it wasn't getting corrected.即使在添加 CLipRRect 之后,它也没有得到纠正。 I also tried to make the container transparent but it showed me an error where I couldn't assign a colour to my container and give it a boxDecoration.I want the excess white part to merge into my background.我还尝试使容器透明,但它显示了一个错误,我无法为我的容器分配颜色并给它一个 boxDecoration。我希望多余的白色部分合并到我的背景中。

//edited //编辑

How do I get rid of the shadow from the background?如何摆脱背景中的阴影?

Widget _bottomNavigationBar(int selectedIndex) => ClipRect(
    child: Container(
        height: 80,
        decoration: BoxDecoration(
          borderRadius: const BorderRadius.all(Radius.circular(52.0)),
          boxShadow: <BoxShadow>[
            BoxShadow(
                color: Colors.grey.withOpacity(0.3),
                offset: const Offset(0.0, 0.0),
                blurRadius: 52.0),
          ],
        ),
        child: ClipRRect(
          borderRadius: BorderRadius.only(
              topLeft: Radius.circular(52.0),
              topRight: Radius.circular(52.0)),
          child: BottomNavigationBar(
            selectedItemColor: Color(0xFFFE524B),
            unselectedItemColor: Color(0xFFFF8C3B),
            onTap: (int index) => setState(() => _selectedIndex = index),
            currentIndex: selectedIndex,
            items: const <BottomNavigationBarItem>[
              BottomNavigationBarItem(
                  icon: Icon(
                    Entypo.home,
                    size: 30,
                  ),
                  title: Text('')),
              BottomNavigationBarItem(
                  icon: Icon(
                    Entypo.game_controller,
                    size: 30,
                  ),
                  title: Text('[![enter image description here][1]][1]')),
              BottomNavigationBarItem(
                  icon: Icon(
                    Entypo.wallet,
                    size: 30,
                  ),
                  title: Text('')),
            ],
          ),
        )),
  );

This is actually not a problem with the bottom navigation bar.这实际上不是底部导航栏的问题。 You need to set "extendBody" to "true" for the parent Scaffold widget.您需要将父 Scaffold 小部件的“extendBody”设置为“true”。 This will extend the scaffold body content all the way down to the bottom of the screen!这会将脚手架主体内容一直延伸到屏幕底部!

Scaffold(
  extendBody: true,
  bottomNavigationBar: _bottomNavigationBar(selectedIndex),
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM