Package 

Class NavHostVisibilityKt

    • Method Summary

      Modifier and Type Method Description
      final static Unit NavHostVisibility(Boolean visible, Function0<Unit> content) Controls the visibility of any NavHost that is placed inside content.
      final static Unit NavHostAnimatedVisibility(Boolean visible, EnterTransition enter, ExitTransition exit, NavTransitionQueueing transitionQueueing, Function1<AnimatedVisibilityScope, Unit> content) Controls the visibility of any NavHost that is placed inside content and animates the appearance and disappearance of it.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • NavHostVisibility

        @Composable() final static Unit NavHostVisibility(Boolean visible, Function0<Unit> content)

        Controls the visibility of any NavHost that is placed inside content. When visible parameter is set to false, content will be removed from composition, all saved states and architecture components (Lifecycle, ViewModelStore, SavedStateRegistry) of NavHost entries will be cleared.

        If you do not want to clear entries' saved states and architecture components, you may hoist NavHostState and use simple condition to control the visibility of NavHost:

        val state = rememberNavHostState(backstack)
        if (visible) {
             NavHost(state) {
                 ...
             }
        }
      • NavHostAnimatedVisibility

        @Composable() final static Unit NavHostAnimatedVisibility(Boolean visible, EnterTransition enter, ExitTransition exit, NavTransitionQueueing transitionQueueing, Function1<AnimatedVisibilityScope, Unit> content)

        Controls the visibility of any NavHost that is placed inside content and animates the appearance and disappearance of it. When visible parameter is set to false, content will be removed from composition, all saved states and architecture components (Lifecycle, ViewModelStore, SavedStateRegistry) of NavHost entries will be cleared.

        If you do not want to clear entries' saved states and architecture components, you may hoist NavHostState and use simple AnimatedVisibility to control the visibility of NavHost:

        val state = rememberNavHostState(backstack)
        AnimatedVisibility(visible) {
             NavHost(state) {
                 ...
             }
        }