英文:
How can i fix the bottom navigator error in dart
问题
以下是您要翻译的内容:
我在Flutter Dart中创建了一个BottomNavigation栏,但出现了错误。
代码如下
错误如下
并且这是错误,请帮助
如果有人能帮助我解决这个错误,我将非常感激
控制台版本如下
英文:
I was making a BottonNavigation bar in flutter dart and i am getting an error
the code is
This the code
the error is
And this the error pls help
I want a solution for this error if someone can help me i will thank them a lot
答案1
得分: 0
你需要在目标参数中传递 NavigationDestination,而不是 NavigationDrawerDestination。
示例代码片段:
bottomNavigationBar: NavigationBar(
onDestinationSelected: (int index) {
setState(() {
currentPageIndex = index;
});
},
selectedIndex: currentPageIndex,
destinations: const <Widget>[
NavigationDestination(
icon: Icon(Icons.explore),
label: 'Explore',
),
NavigationDestination(
icon: Icon(Icons.commute),
label: 'Commute',
),
NavigationDestination(
selectedIcon: Icon(Icons.bookmark),
icon: Icon(Icons.bookmark_border),
label: 'Saved',
),
],
),
请参考官方文档:https://api.flutter.dev/flutter/material/NavigationBar-class.html
或者,如果您正在使用其他包,请查阅其文档。
或者,您也可以使用https://api.flutter.dev/flutter/material/BottomNavigationBar-class.html。
英文:
you need to pass NavigationDestination instead of NavigationDrawerDestination in the destinations params
** sample code snippet **
bottomNavigationBar: NavigationBar(
onDestinationSelected: (int index) {
setState(() {
currentPageIndex = index;
});
},
selectedIndex: currentPageIndex,
destinations: const <Widget>[
NavigationDestination(
icon: Icon(Icons.explore),
label: 'Explore',
),
NavigationDestination(
icon: Icon(Icons.commute),
label: 'Commute',
),
NavigationDestination(
selectedIcon: Icon(Icons.bookmark),
icon: Icon(Icons.bookmark_border),
label: 'Saved',
),
],
),
follow official documentation https://api.flutter.dev/flutter/material/NavigationBar-class.html (material you/3)
or If you are using other package for it check its documentation
or you can also use
https://api.flutter.dev/flutter/material/BottomNavigationBar-class.html (material 2)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论