【发布时间】:2019-05-18 12:02:14
【问题描述】:
我不确定在使用 BottomNavBar 时应该如何构建我的页面。
现在,我使用 MainScreen,其中包含 Scaffold 和 BottomNavBar
MainScreen 小部件包含一个包含不同页面的列表。这是使用底部导航栏的推荐方式吗?我知道我也可以使用 Navigator 在屏幕之间导航,但是它会为每个页面启动一个不同的窗口,这不是您在使用 bottomNavBar 时所期望的。我现在实现它的方式工作正常,但我怎么能在其中一个屏幕中使用FloatingActionButton?你总是需要一个脚手架吗?
List<Widget> screens = [
Screen1(),
Screen2(),
Screen3()
];
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(Constants.APP_NAME),
),
body: screens[_currentIndex],
bottomNavigationBar: CustomBottomNav(onBottomNavPressed: onBottomNavPressed,),
);
}
【问题讨论】:
-
你想在其中一个屏幕上显示 fab,对吧?