How to set border radius to bottom app bar in a flutter app?

前端 未结 3 406
深忆病人
深忆病人 2021-01-02 06:03

I want to set the borderRadius to an Bottom Navigation App Bar as its shown in the image. I have tried to put Bottom Navigation App Bar to a

3条回答
  •  离开以前
    2021-01-02 06:44

    Put it inside a stack. Don't add the Bottom Navigation Bar to the scaffold directly.

    class HomePage extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text('Some Text'),
          ),
          body: Stack(
            children: [
              bodyContent,
              Positioned(
                left: 0,
                right: 0,
                bottom: 0,
                child: bottomNavigationBar,
              ),
            ],
          ),
        );
      }
    
      Widget get bodyContent {
        return Container(color: Colors.red);
      }
    
      Widget get bottomNavigationBar {
        return ClipRRect(
          borderRadius: BorderRadius.only(
            topRight: Radius.circular(40),
            topLeft: Radius.circular(40),
          ),
          child: BottomNavigationBar(
            items: [
              BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('1')),
              BottomNavigationBarItem(icon: Icon(Icons.usb), title: Text('2')),
              BottomNavigationBarItem(
                  icon: Icon(Icons.assignment_ind), title: Text('3')),
              BottomNavigationBarItem(
                  icon: Icon(Icons.multiline_chart), title: Text('4')),
            ],
            unselectedItemColor: Colors.grey,
            selectedItemColor: Colors.black,
            showUnselectedLabels: true,
          ),
        );
      }
    }
    

    Output

提交回复
热议问题