Controller

class Controller<T : Route>

A controller to manage navigation for Route T.

One can create an instance using rememberNavController for setting up navigation through navigator.Setup(...).

One can retrieve an instance of controller using findNavController& passing the required Navigation root key.

See also

Functions

Link copied to clipboard
fun canGoBack(): Boolean
Link copied to clipboard
fun closeDialog(key: KClass<out DialogRoute>): DialogRoute

Force dismiss an ongoing dialog which is currently being shown or was in the backStack. This respects neither handleOnDismissRequest nor DialogScope.goBack's backstack.

Link copied to clipboard
@Composable
fun <T : DialogRoute> CreateDialog(key: KClass<T>, dialogProperties: DialogProperties = DialogProperties(), handleOnDismissRequest: () -> Boolean = { false }, content: @Composable ComposeNavigator.DialogScope<T>.() -> Unit)

Setup a composable that will be displayed in the Dialog with the backStack functionality.

Link copied to clipboard
fun getAllDialogHistory(): List<DialogRoute>
Link copied to clipboard
fun getAllHistory(): List<T>
Link copied to clipboard
fun getCurrentRouteAsFlow(): Flow<T>
Link copied to clipboard
fun goBack(): T?

Go back to the previous destination.

Link copied to clipboard
fun goBackToRoot(): List<T>

Jump back to the root destination.

Link copied to clipboard
fun goBackUntil(destKey: KClass<out T>, inclusive: Boolean = false): List<T>

Go back until the required destination is satisfied by destKey parameter (inclusive or not).

Link copied to clipboard
fun navigateTo(destination: T, options: NavOptions<T>.() -> Unit = {})

Navigate to a new destination of type T. Additional parameters can be set through options DSL.

Link copied to clipboard
fun <T : DialogRoute> showDialog(key: T)

Show a dialog which was created before using CreateDialog.

Properties

Link copied to clipboard
val currentRoute: T?

The current active Route in the navigation history.

Link copied to clipboard
var enableDialogOverlay: Boolean = false

When there are multiple dialogs to show on the screen each dialog content composable will be stacked upon one another.

Link copied to clipboard
val parentRoute: Route?

The parent Route associated with this nested navigation if it already is otherwise null.