NavDestinationBuilder

public class NavDestinationBuilder<D extends NavDestination>

Known indirect subclasses

DSL for constructing a new NavDestination

Summary

Public fields

final int

The destination's unique ID.

final @Nullable CharSequence

The descriptive label of the destination

final @Nullable String

The destination's unique route.

Public constructors

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

DSL for constructing a new NavDestination with a unique id.

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

DSL for constructing a new NavDestination with a unique route.

Public methods

final void
action(
    int actionId,
    @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,
    @NonNull Function1<@NonNull NavArgumentBuilderUnit> argumentBuilder
)

Add a NavArgument to this destination.

@NonNull D

Build the NavDestination by calling Navigator.createDestination.

final void
deepLink(@NonNull String uriPattern)

Add a deep link to this destination.

final void
deepLink(
    @NonNull Function1<@NonNull NavDeepLinkDslBuilderUnit> navDeepLink
)

Add a deep link to this destination.

Public fields

id

@NonNull
public final int id

The destination's unique ID.

label

@Nullable
public final @Nullable CharSequence label

The descriptive label of the destination

route

@Nullable
public final @Nullable String route

The destination's unique route.

Public constructors

public final <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 final <D extends NavDestination> NavDestinationBuilder(
    @NonNull Navigator<@NonNull D> navigator,
    @Nullable 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

@Nullable String route

the destination's unique route

Returns
NavDestinationBuilder<@NonNull D>

the newly constructed NavDestination

Public methods

action

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

Adds a new NavAction to the destination

argument

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

Add a NavArgument to this destination.

build

@NonNull
public D build()

Build the NavDestination by calling Navigator.createDestination.

deepLink

@NonNull
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

deepLink

@NonNull
public final void deepLink(
    @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
@NonNull Function1<@NonNull NavDeepLinkDslBuilderUnit> navDeepLink

the NavDeepLink to be added to this destination