【发布时间】:2021-08-13 16:41:34
【问题描述】:
我正在创建这个应用程序,并添加了一个底部导航栏,除了背景颜色之外,一切正常。我希望根据选择的项目来改变背景。当我使用type: BottomNavigationBarType.shifting 时它工作得很好,但当我将它更改为type: BottomNavigationBarType.fixed 时就不行了。
问题是我不喜欢“shifting”的行为,我更喜欢“fixed”的行为。
我找到了这个例子online,但是它使用了shifting类型:
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
backgroundColor: Colors.teal
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
label: 'Profile',
backgroundColor: Colors.cyan
),
BottomNavigationBarItem(
icon: Icon(Icons.settings),
label: 'Settings',
backgroundColor: Colors.lightBlue,
),
],
type: BottomNavigationBarType.shifting,
currentIndex: _selectedIndex,
selectedItemColor: Colors.white,
unselectedItemColor: Colors.grey,
iconSize: 40,
onTap: _onItemTap,
elevation: 5
)
如何使用type: BottomNavigationBarType.fixed 使用底部导航栏实现相同的背景颜色变化效果?
提前致谢。
【问题讨论】:
-
根据所选择的项目用容器颜色包装怎么样?
标签: flutter dart flutter-bottomnavigation