Closed jitendravn closed 1 week ago
Assume i have Dynamic menu list dynamicMenu=[Page1(),Page2(),Page3()] @agordn52 then how can add this in Base navigation hu
/// Navigation pages _BaseNavigationHubState() : super(() async { return {}; }); /// Handle the tap event @override onTap(int index) { super.onTap(index); } bottomNavigation() { dynamicMenus.map((page) { int pageIndex = dynamicMenus.indexOf(page); return { pageIndex: NavigationTab.badge( tooltip: 'page.value.tooltip', title:getLabelForPage(page), page: page, // create using: 'dart run nylo_framework:main make:stateful_widget home_tab' icon: isPageEnumType ? getIconForPage( page, currentIndex == pageIndex : Icon(fontAwesomeIcons[page['icon']]), activeIcon: isPageEnumType ? getIconForPage( page,currentIndex == pageIndex : Icon(fontAwesomeIcons[page['icon']]), ), }; }); }`
i have same problem !!
Hi @jitendravn and @SumitCodoffer,
Have your read and understood the docs for Navigation Hubs?
This would never work since you are not returning the expected map of NavgiationTabs.
/// Navigation pages
_BaseNavigationHubState()
: super(() async {
return {};
});
Instead, map your tabs inside the async callback
/// Navigation pages
_BaseNavigationHubState()
: super(() async {
final myExamplePages = [];
/// map 'myExamplePages' to NavigationTabs with the index being the key. E.g.
return {
0: NavigationTab(
title: "Home",
page: HomeTab(),
icon: Icon(Icons.home),
activeIcon: Icon(Icons.home_filled),
),
1: NavigationTab(...,
2: NavigationTab(...
...
};
});
No, I think you are not properly getting me. return { 0: NavigationTab( title: "Home", page: HomeTab(), icon: Icon(Icons.home), activeIcon: Icon(Icons.home_filled), ), 1: NavigationTab(..., 2: NavigationTab(... ... };
this is what I think when we have a static page means not dynamic. but in my case I have dynamic so how can I call my dynamic routes IN constructor @agordn52
/// Navigation pages setup
Map<int, NavigationTab> bottomNavigation() {
return {
for (int pageIndex = 0;
pageIndex < widget.controller.receivedPages.length;
pageIndex++)
pageIndex: _buildNavigationTab(pageIndex),
};
}
/// Navigation pages
_BaseNavigationHubState()
: super(() async {
return {};
});
/// Handle the tap event
@override
onTap(int index) {
super.onTap(index);
}
/// Helper method to build NavigationTab
NavigationTab _buildNavigationTab(int pageIndex) {
var page = widget.controller.receivedPages[pageIndex];
bool isPageEnumType = page.runtimeType == PagesEnum;
return NavigationTab.badge(
tooltip: 'page.value.tooltip',
title: isPageEnumType ? getLabelForPage(page) : page['label'],
page: page,
icon: isPageEnumType
? getIconForPage(page, widget.controller.currentIndex == pageIndex)
: Icon(fontAwesomeIcons[page['icon']]),
activeIcon: isPageEnumType
? getIconForPage(page, widget.controller.currentIndex == pageIndex)
: Icon(
fontAwesomeIcons[page['icon']],
),
);
}
Assume i have Dynamic menu list dynamicMenu=[Page1(),Page2(),Page3()] @agordn52 then how can add this in Base navigation hu