Navigatore.push上的Flutter Remove Bottom底部导航栏

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

我正在处理带有抖动的项目,我有一个底部导航栏,该导航栏允许我在不同的场景上移动。导航到详细信息页面时,我想删除底部的导航栏,有什么方法吗?我正在尝试所有可能的解决方案,但是我无法解决问题,也许我的导航栏实现不正确!

某些代码:

我在首页中实现了底部导航栏,并在其中调用所有其他页面的地方:

class homeScreen extends StatefulWidget {
  @override
  _homeScreenState createState() => _homeScreenState();
}

class _homeScreenState extends State<homeScreen> {
  TextEditingController _linkController;
  int _currentIndex = 0;
  final _pageOptions = [
    meetingScreen(),
    dashboardScreen(),
    notificationScreen(),
    profileScreen(),

  ];


  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _linkController = new TextEditingController();

  }

  @override
  Widget build(BuildContext context) {
    ScreenUtil.instance = ScreenUtil(width: 1125, height: 2436)..init(context);

    return MaterialApp(
      title: myUi.myTitle,
      theme: myUi.myTheme ,
      debugShowCheckedModeBanner: false,
      home:Scaffold(

        bottomNavigationBar: _buildBottomNavigationBar(),
        body: _pageOptions[_currentIndex] ,

      ) ,
    );

  }


  Widget _buildBottomNavigationBar() {
    return BottomNavigationBar(
      backgroundColor: Colors.white,
      selectedItemColor: Theme.of(context).primaryColor,
      //fixedColor: gvar.secondaryColor[gvar.colorIndex],

      currentIndex: _currentIndex,
      onTap: (index) {
        setState(() {
          _currentIndex = index;
        });
      },
      type: BottomNavigationBarType.fixed,

      items: [
        BottomNavigationBarItem(

            icon: Icon(Icons.explore,size: ScreenUtil().setWidth(80),),
            title: new Text("Esplora"),
        ),

        BottomNavigationBarItem(
          icon:Icon(Icons.dashboard,size: ScreenUtil().setWidth(80),),
          title: new Text("Attività"),

        ),

        BottomNavigationBarItem(
          icon:Icon(Icons.notifications,size: ScreenUtil().setWidth(80),),
          title: new Text("Notifiche"),

        ),

        BottomNavigationBarItem(
          icon:Icon(Icons.person,size: ScreenUtil().setWidth(80),),
          title: new Text("Profilo"),

        ),



      ],
    );
  }
}

这是我在dashboardScreen中使用的用于推送到我的详细信息页面的代码:

            onTap: () {
              //method: navigate to Meeting

              Navigator.push(context, MaterialPageRoute(
                    builder: (BuildContext context) =>  new meetingScreen()),
              );

            },

在新的MeetingScreen中,我有一些ui,但是我无法删除旧的底部导航栏,我尝试实现一个新的导航栏,但未显示。

部分可行的解决方案是这样:

Navigator.of(context, rootNavigator: true).pushReplacement(MaterialPageRoute(builder: (context) => new meetingScreen()));

但是现在我无法使用炫酷的动画来做Navigator.pop,因为新页面是根!

谢谢大家的支持!

flutter navigator
1个回答
0
投票

将导航栏作为组件安装,然后在主屏幕上使用它。也请遵循Dart API库。以下链接将对您有所帮助。

Dart API Library

© www.soinside.com 2019 - 2024. All rights reserved.