NavDestinationBuilder

@NavDestinationDsl
public class NavDestinationBuilder<D extends NavDestination>

Known indirect subclasses

DSL for constructing a new NavDestination

Summary

Public constructors

<D extends NavDestination> NavDestinationBuilder(
    @NonNull Navigator<@NonNull D> navigator,
    @IdRes int id
)

This method is deprecated. Use routes to build your NavDestination instead

<D extends NavDestination> NavDestinationBuilder(
    @NonNull Navigator<@NonNull D> navigator,
    String route
)

DSL for constructing a new NavDestination with a unique route.

Public methods

final void
action(
    int actionId,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavActionBuilderUnit> actionBuilder
)

This method is deprecated. Building NavDestinations using IDs with the Kotlin DSL has been deprecated in favor of using routes.

final void
argument(
    @NonNull String name,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavArgumentBuilderUnit> argumentBuilder
)

Add a NavArgument to this destination.

@NonNull D

Build the NavDestination by calling Navigator.createDestination.

final void

Add a deep link to this destination.

final void
deepLink(@NonNull String uriPattern)

Add a deep link to this destination.

final int

The destination's unique ID.

final CharSequence

The descriptive label of the destination

final String

The destination's unique route.

final void

The descriptive label of the destination

Protected methods

final @NonNull Navigator<@NonNull D>

The navigator the destination was created from

Public constructors

public <D extends NavDestination> NavDestinationBuilder(
    @NonNull Navigator<@NonNull D> navigator,
    @IdRes int id
)

DSL for constructing a new NavDestination with a unique id.

This sets the destination's route to null.

Parameters
@NonNull Navigator<@NonNull D> navigator

navigator used to create the destination

@IdRes int id

the destination's unique id

Returns
NavDestinationBuilder<@NonNull D>

the newly constructed NavDestination

public <D extends NavDestination> NavDestinationBuilder(
    @NonNull Navigator<@NonNull D> navigator,
    String route
)

DSL for constructing a new NavDestination with a unique route.

This will also update the id of the destination based on route.

Parameters
@NonNull Navigator<@NonNull D> navigator

navigator used to create the destination

String route

the destination's unique route

Returns
NavDestinationBuilder<@NonNull D>

the newly constructed NavDestination

Public methods

action

Added in 1.0.0
public final void action(
    int actionId,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavActionBuilderUnit> actionBuilder
)

Adds a new NavAction to the destination

argument

Added in 1.0.0
public final void argument(
    @NonNull String name,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavArgumentBuilderUnit> argumentBuilder
)

Add a NavArgument to this destination.

build

Added in 1.0.0
public @NonNullbuild()

Build the NavDestination by calling Navigator.createDestination.

deepLink

Added in 2.3.0
public final void deepLink(
    @ExtensionFunctionType @NonNull Function1<@NonNull NavDeepLinkDslBuilderUnit> navDeepLink
)

Add a deep link to this destination.

In addition to a direct Uri match, the following features are supported:

  • Uris without a scheme are assumed as http and https. For example, www.example.com will match http://www.example.com and https://www.example.com.

  • Placeholders in the form of {placeholder_name} matches 1 or more characters. The String value of the placeholder will be available in the arguments Bundle with a key of the same name. For example, http://www.example.com/users/{id} will match http://www.example.com/users/4.

  • The .* wildcard can be used to match 0 or more characters.

Parameters
@ExtensionFunctionType @NonNull Function1<@NonNull NavDeepLinkDslBuilderUnit> navDeepLink

the NavDeepLink to be added to this destination

deepLink

Added in 1.0.0
public final void deepLink(@NonNull String uriPattern)

Add a deep link to this destination.

In addition to a direct Uri match, the following features are supported:

  • Uris without a scheme are assumed as http and https. For example, www.example.com will match http://www.example.com and https://www.example.com.

  • Placeholders in the form of {placeholder_name} matches 1 or more characters. The String value of the placeholder will be available in the arguments Bundle with a key of the same name. For example, http://www.example.com/users/{id} will match http://www.example.com/users/4.

  • The .* wildcard can be used to match 0 or more characters.

Parameters
@NonNull String uriPattern

The uri pattern to add as a deep link

See also
deepLink

getId

Added in 1.0.0
public final int getId()

The destination's unique ID.

getLabel

Added in 1.0.0
public final CharSequence getLabel()

The descriptive label of the destination

getRoute

public final String getRoute()

The destination's unique route.

setLabel

Added in 1.0.0
public final void setLabel(CharSequence label)

The descriptive label of the destination

Protected methods

getNavigator

Added in 1.0.0
protected final @NonNull Navigator<@NonNull D> getNavigator()

The navigator the destination was created from