admin管理员组文章数量:1391969
I am trying to add a new screen in my flutter app however if the navigation bar has more than three destinations I get this error:
package:flutter/src/material/navigation_bar.dart': Failed assertion: line 117 pos 15: '0 <= selectedIndex && selectedIndex < destinations.length': is not true.
I have a temporary fix by just modifying the navigation.dart file of flutter but when it comes to production that may not be good.
is there anything else I could do?
here is my code for reference:
return Scaffold(
backgroundColor: Palette.backgroundColor,
bottomNavigationBar: NavigationBar(
height: MediaQuery.of(context).size.width * 0.18,
onDestinationSelected: (int index) {
setState(() {
currentPageIndex = index;
});
},
backgroundColor: Colors.white,
indicatorColor: Palette.iconBackground,
selectedIndex: currentPageIndex,
destinations: <Widget>[
NavigationDestination(
// home
selectedIcon: Icon(Icons.home),
icon: Icon(Icons.home_outlined),
label: 'Home',
),
// paymemts/notifications
NavigationDestination(
selectedIcon: Icon(Icons.payments),
icon: Icon(Icons.payments_outlined),
label: 'Payments',
),
NavigationDestination(
selectedIcon: Icon(Icons.payments),
icon: Icon(Icons.payments_outlined),
label: 'test',
),
// profile
NavigationDestination(
selectedIcon: Icon(Icons.person),
icon: Icon(Icons.person_outline),
label: 'Profile',
)
]),
//body to store outstanding balance and sis nav cards
body: IndexedStack(
index: currentPageIndex,
children: [
DashboardScreen(
name: GetProfileData.displayName(name),
email: email,
),
const NotifPage(),
const ComingSoonPage(),
const ProfileScreen(),
],
),
);
本文标签: flutterDoes the navigation bar widget allow at most only 3 destinationsStack Overflow
版权声明:本文标题:flutter - Does the navigation bar widget allow at most only 3 destinations? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744717817a2621511.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论