Package 

Class NavBackHandlerKt

    • Method Summary

      Modifier and Type Method Description
      final static <T extends Any> <ERROR CLASS> NavBackHandler(NavController<T> controller, Boolean enabled, Boolean allowEmptyBackstack) Convenient BackHandler implementation that supports the most basic logic of back navigation.
      • Methods inherited from class java.lang.Object

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

      • NavBackHandler

        @Composable() final static <T extends Any> <ERROR CLASS> NavBackHandler(NavController<T> controller, Boolean enabled, Boolean allowEmptyBackstack)

        Convenient BackHandler implementation that supports the most basic logic of back navigation.

        The underlying BackHandler will be kept enabled while the controller contains more than one entry in its backstack. The back button press will cause a single NavController.pop. This way the back handling may be delegated to upper BackHandlers when there are no more items to pop off without leaving the backstack completely empty.

        If you want to allow NavBackHandler to remove the last entry as well, you may set allowEmptyBackstack to true. For example, allowEmptyBackstack = true should be used in pair with BottomSheetNavHost.

        For any more specific use-cases feel free to use BackHandler directly and define your own behaviour.

        IMPORTANT NOTICE: place your NavBackHandler or BackHandler in a composable before a corresponding NavHost. As both BackHandler and NavHost use Lifecycle under the hood, there is a case when the order of back handling may be restored incorrectly after a process/activity recreation. This is how the framework works and there is nothing to do about it. Simple placement of BackHandler before NavHost guarantees no issues in this part.

        Parameters:
        enabled - if this NavBackHandler should be enabled.