Flutter:所有页面上的弯曲底部导航栏,从主页开始

时间:2020-04-09 18:48:09

标签: flutter navigation

我有一个弯曲的底部导航栏,我想在主屏幕上开始。之后会转到此页面,但我希望从这里开始。我还需要在所有屏幕上显示导航栏。我该如何解决这两个问题?

class BottomNavBar extends StatefulWidget {

  @override
  _BottomNavBarState createState() => _BottomNavBarState();
}

class _BottomNavBarState extends State<BottomNavBar> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        color: Color(0xff3a3535),
        height: MediaQuery.of(context).size.height,
        width: MediaQuery.of(context).size.width,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
        ),
      ),
      bottomNavigationBar: CurvedNavigationBar(
        color: Colors.white,
        backgroundColor: Color(0xff3a3535),
        buttonBackgroundColor: Colors.white,
        height: 50.0,
        items: <Widget>[
          Icon(Icons.subject,
            size: 20, color: Colors.black,),
          Icon(Icons.assignment,
            size: 20.0, color: Colors.black,),
          Icon(Icons.collections_bookmark,
            size: 20.0, color: Colors.black,),
        ],
        animationDuration: Duration(
            microseconds: 200),
        index: 1,
        animationCurve: Curves.bounceInOut,
        onTap: (index) {
          switch (index) {
            case 0:
              Navigator.push(context, MaterialPageRoute(
                  builder: (context) => NewsHome()));
              break;
            case 1:
              Navigator.push(context, MaterialPageRoute(
                  builder: (context) => HomeScreen()));
              break;
            case 2:
              Navigator.push(context, MaterialPageRoute(
                  builder: (context) => PoemsPage()));
              break;
          }
        }
      ),
    );
  }
}

0 个答案:

没有答案