'Jetpack compose bottom navigation

The official example to create bottom navigation shows the need of sealed class, list of screen and such(link to official example). Why not just toggle between screen

 BottomNavigationItem(icon = {
        Icon(imageVector = Icons.Default.Person,"")
    },
        label = { Text(text = "Profile") }, 
        selected = (selectedIndex.value == 2), 
        onClick = {
            selected=Composable fun1
   }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source