Flutter BackButton和BottomNavigationBar

Flutter BackButton和BottomNavigationBar,flutter,dart,navigation,back,Flutter,Dart,Navigation,Back,我想要在我的页面之间导航,当我在设置页面上时,我想要一个返回按钮,将我带到主页,对收藏夹也是如此,从我的页面还有一个底部导航栏,允许你在它们之间导航。我已经尝试使用Navigator()了,但它迫使我在主页上放置另一个按钮。我不知道我是否说清楚了,但我希望你能帮助我 谢谢大家! 更新:我使用了getX的软件包。如果设置页面没有底部的应用程序栏,那么你可以使用Navigator.of(context).pop(),或者你可以使用顶部的应用程序栏并设置automaticallyImplyLeadin

我想要在我的页面之间导航,当我在设置页面上时,我想要一个返回按钮,将我带到主页,对收藏夹也是如此,从我的页面还有一个底部导航栏,允许你在它们之间导航。我已经尝试使用Navigator()了,但它迫使我在主页上放置另一个按钮。我不知道我是否说清楚了,但我希望你能帮助我

谢谢大家!


更新:我使用了getX的软件包。

如果设置页面没有底部的应用程序栏,那么你可以使用
Navigator.of(context).pop()
,或者你可以使用顶部的应用程序栏并设置
automaticallyImplyLeading=true
来显示一个也会弹出的后退按钮

下面是我的一个底部应用程序栏的示例,它允许在多个页面上进行平滑导航:

class _MainScreenState extends State<MainScreen> {
 

  int _currentIndex = 0;
  final List<Widget> _children = [
    Home(),
    InboxMain(),
    DashboardMain(),
    ProfileMain(),
    FriendsMain()
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _children[_currentIndex],
      bottomNavigationBar: new Theme(
        data: Theme.of(context).copyWith(
          canvasColor: Color.fromRGBO(41, 34, 78, 1),
        ), //
        child: BottomNavigationBar(
          //selectedItemColor: Colors.red,
          //selectedIconTheme: IconThemeData(color: Colors.red),
          type: BottomNavigationBarType.fixed,  
          showSelectedLabels: false,
          showUnselectedLabels: false,
          backgroundColor: Color.fromRGBO(41, 34, 78, 1),
          onTap: onTabTapped,
          currentIndex: _currentIndex,
          items: [
            BottomNavigationBarItem(
                icon: _currentIndex == 0
                    ?  Icon(Icons.home_outlined, color: Colors.white)
                    : Icon(
                        Icons.home_outlined,
                        color: Colors.grey[600],
                      ),
                title: Container(
                  height: 0,
                )),
            BottomNavigationBarItem(
                icon: _currentIndex == 1
                    ? Icon(
                        Icons.email_outlined,
                        color: Colors.white,
                      )
                    : Icon(
                        Icons.email_outlined,
                        color: Colors.grey[600],
                      ),
                title: Container(
                  height: 0,
                )),
            BottomNavigationBarItem(
                icon: _currentIndex == 2
                    ? Icon(Icons.dashboard, color: Colors.white)
                    : Icon(Icons.dashboard, color: Colors.grey[600]),
                title: Container(
                  height: 0,
                )),
            BottomNavigationBarItem(
                icon: _currentIndex == 3
                    ? Icon(
                        Icons.person,
                        color: Colors.white,
                      )
                    : Icon(Icons.person, color: Colors.grey[600]),
                title: Container(
                  height: 0,
                )),
            BottomNavigationBarItem(
                icon: _currentIndex == 4
                    ? Icon(
                        Icons.people_alt,
                        color: Colors.white,
                      )
                    : Icon(Icons.people_alt, color: Colors.grey[600]),
                title: Container(
                  height: 0,
                )),
          ],
        ),
      ),
    );
  }

  void onTabTapped(int index) {
    setState(() {
      _currentIndex = index;
    });
  }
}
class\u MainScreenState扩展状态{
int _currentIndex=0;
最终列表_子项=[
Home(),
InboxMain(),
DashboardMain(),
ProfileMain(),
友谊
];
@凌驾
小部件构建(构建上下文){
返回脚手架(
正文:_children[_currentIndex],
底部导航栏:新主题(
数据:Theme.of(context).copyWith(
画布颜色:颜色。来自RGBO(41,34,78,1),
), //
子项:底部导航栏(
//选择编辑颜色:Colors.red,
//选择主题:图标主题数据(颜色:Colors.red),
类型:BottomNavigationBarType.fixed,
showSelectedLabels:false,
显示未选择的标签:false,
背景颜色:颜色。来自RGBO(41,34,78,1),
onTap:onTabTapped,
currentIndex:_currentIndex,
项目:[
底部导航气压计(
图标:_currentIndex==0
?图标(Icons.home\u轮廓,颜色:Colors.white)
:图标(
Icons.home_概述,
颜色:颜色。灰色[600],
),
标题:集装箱(
高度:0,,
)),
底部导航气压计(
图标:_currentIndex==1
?图标(
Icons.email_概述,
颜色:颜色,白色,
)
:图标(
Icons.email_概述,
颜色:颜色。灰色[600],
),
标题:集装箱(
高度:0,,
)),
底部导航气压计(
图标:_currentIndex==2
?图标(图标。仪表板,颜色:颜色。白色)
:Icon(Icons.dashboard,颜色:Colors.grey[600]),
标题:集装箱(
高度:0,,
)),
底部导航气压计(
图标:_currentIndex==3
?图标(
一个人,
颜色:颜色,白色,
)
:Icon(Icons.person,颜色:Colors.grey[600]),
标题:集装箱(
高度:0,,
)),
底部导航气压计(
图标:_currentIndex==4
?图标(
Icons.people\u alt,
颜色:颜色,白色,
)
:Icon(Icons.people\u alt,颜色:Colors.grey[600]),
标题:集装箱(
高度:0,,
)),
],
),
),
);
}
void onTabTapped(整数索引){
设置状态(){
_currentIndex=索引;
});
}
}

我的应用程序(登录后)导航到此位置,所有导航都在此处控制,除了使用后退按钮和
pop()

的扩展屏幕之外,我已经有了底部导航栏。我想在“我的收藏”和“我的设置”屏幕的应用栏中创建一个后退按钮,而不是在“我的主屏幕”的应用栏中。“Back”按钮将转到“Homme”页面。