Skip to content

Commit 8b3ecff

Browse files
authored
Merge pull request #6 from HardikSJain/bug-fix
fix: bottom navigation current index by HardikSJain
2 parents 4882d04 + 1180864 commit 8b3ecff

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/app/routes/screen_extension.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,14 @@ extension ScreenExtension on Screen {
110110

111111
extension RoleExtension on Role {
112112
int getCurrentIndexFromRoute(GetNavConfig? currentRoute) {
113-
final String? currentLocation = currentRoute?.location;
113+
final String? currentLocation = currentRoute?.uri.path;
114114
int currentIndex = 0;
115115
if (currentLocation != null) {
116-
currentIndex =
117-
tabs.indexWhere((tab) => currentLocation.startsWith(tab.path));
116+
currentIndex = tabs.indexWhere((tab) {
117+
String parentPath = tab.parent?.path ?? '';
118+
String fullPath = '$parentPath${tab.path}';
119+
return currentLocation.startsWith(fullPath);
120+
});
118121
}
119122
return (currentIndex > 0) ? currentIndex : 0;
120123
}

0 commit comments

Comments
 (0)