Highlighting the Selected Route
Sync selection with the back stack.
Selection Must Be Real
A tab should light up because of where the user actually is, not a value you set by hand. The back stack is your source of truth. 🧭
Read the Current Entry
Ask the NavController for the live currentBackStackEntryAsState. It updates automatically every time navigation changes.
val entry by navController.currentBackStackEntryAsState()All lessons in this course
- NavigationBar with Multiple Tabs
- Highlighting the Selected Route
- Preserving Tab State on Switch
- TabRow & Swipeable Pages