I cannot answer you exactly how to fix the flickering, but I can tell you that the recommended way to work with a Navigation component, TopBars and BottomBars in Jetpack Compose, is to use the Scaffold component and the navigation-compose component.
Compose Navigation component dependency:
// Navigation
implementation "androidx.navigation:navigation-compose:1.0.0-alpha09"
It is still in alpha, but so far it has been working really well. Just try to keep posted about all updates.
Example usage:
@Composable
fun App() {
val navController = rememberNavController()
Scaffold(
topBar = {
TopAppBar {
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
Text(text = "App Title")
}
}
},
bottomBar = {
BottomAppBar {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically
) {
TextButton(onClick = { navController.navigate("home") }) {
Text(text = "Home")
}
TextButton(onClick = { navController.navigate("favorites") }) {
Text(text = "Favorites")
}
TextButton(onClick = { navController.navigate("profile") }) {
Text(text = "Profile")
}
}
}
}
) {
NavHost(navController, startDestination = "home") {
composable("home") {
Home()
}
composable("favorites") {
Favorites()
}
composable("profile") {
Profile()
}
}
}
}