【发布时间】:2021-05-12 13:43:01
【问题描述】:
我遇到了地图循环问题,我无法映射我的项目列表 也许这是因为是参考列表?有什么解决方案可以改变这样做的形状吗?
我的代码:
NavigationRoute initialRoute = NavigationRoute(
route: '/',
widget: Home(),
);
NavigationRoute home = NavigationRoute(
title: 'Home',
route: '/home',
icon: Icons.home,
color: Colors.teal,
widget: Home(),
);
NavigationRoute cardsNavigator = NavigationRoute(
title: 'Cards',
route: '/cardsNavigator',
icon: Icons.card_giftcard,
color: Colors.teal,
widget: CardsNavigator(),
);
NavigationRoute example = NavigationRoute(
title: 'Example',
route: '/example',
icon: Icons.business,
color: Colors.teal,
widget: ExamplePage(),
);
List<NavigationRoute> navigation = <NavigationRoute>[
initialRoute,
home,
cardsNavigator,
example,
];
我试图在项目地图中使用它:
bottomNavigationBar: BottomNavigationBar(
currentIndex: currentIndex,
onTap: (index) {
setState(() {
currentIndex = index;
digitalBankingNavigator.currentState?.pushNamed(
digitalBankingRoutes.navigation[currentIndex].route);
});
},
items: digitalBankingRoutes.navigation
.map((route) => BottomNavigationBarItem(
icon: Icon(route.icon),
label: route.title,
backgroundColor: route.color))
.toList(),
),
【问题讨论】:
-
你能分享一下显示错误吗?
-
@MiguelEscobarCalderon 没有显示错误,我认为这是因为这是一个引用列表(因为当我调试时,我无法访问对象)