Flutter 显示底部导航栏,但未选择其任何项目
这是我的底部导航栏,现在我想显示底部导航栏,但最初它的项目没有被选中。当我将_selectedIndex设置为null时,我得到一个错误。 有什么办法可以做到这一点Flutter 显示底部导航栏,但未选择其任何项目,flutter,dart,flutter-layout,Flutter,Dart,Flutter Layout,这是我的底部导航栏,现在我想显示底部导航栏,但最初它的项目没有被选中。当我将_selectedIndex设置为null时,我得到一个错误。 有什么办法可以做到这一点 int _selectedIndex = 0; BottomNavigationBar( backgroundColor: Colors.blueAccent, unselectedItemColor: Colors.white, items: [ BottomNavigationBarItem(
int _selectedIndex = 0;
BottomNavigationBar(
backgroundColor: Colors.blueAccent,
unselectedItemColor: Colors.white,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.add),
title: Text(''),
),
BottomNavigationBarItem(
icon: Icon(Icons.camera_alt),
title: Text(''),
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
title: Text(''),
),
],
currentIndex: _selectedIndex,
onTap: (index) {
setState(() {
_selectedIndex = index;
});
},
);
与此情况类似: