I want to do navigation with Scaffold
and BottomNavigation
in Jetpack Compose. They are in the MainPage. But when I click the content in the MainPage and navigate to DetailPage, the BottomNavigation
also exist, like the image:
How can I hide the BottomNavigation
in the DetailPage?
You need to specify which screens you want to show and which screens you dont want; Otherwise it will show to all the screens inside
Scaffold
's body (which you havebottomBar
). The code below was from my app.Create a state which observes any destination changes on the navController
Inside
when
you can put any screens that you want to shownavigationBar
else just setcurrentScreen
toNoBottomBar
On the Scaffold where you put ur bottomBar
so you can check if
currentScreen
wasNoBottomBar
if it was, don't show it