NavArgument.Builder



A builder for constructing NavArgument instances.

Summary

Public constructors

android

Public functions

NavArgument

Build the NavArgument specified by this builder.

android
NavArgument.Builder
setDefaultValue(defaultValue: Any?)

Specify the default value for an argument.

android
NavArgument.Builder
setIsNullable(isNullable: Boolean)

Specify if the argument is nullable.

android
NavArgument.Builder
<T : Any?> setType(type: NavType<T>)

Set the type of the argument.

android

Public constructors

Builder

Builder()

Public functions

build

fun build(): NavArgument

Build the NavArgument specified by this builder. If the type is not set, the builder will infer the type from the default argument value. If there is no default value, the type will be unspecified.

Returns
NavArgument

the newly constructed NavArgument.

setDefaultValue

fun setDefaultValue(defaultValue: Any?): NavArgument.Builder

Specify the default value for an argument. Calling this at least once will cause the argument to have a default value, even if it is set to null.

Parameters
defaultValue: Any?

Default value for this argument. Must match NavType if it is specified.

Returns
NavArgument.Builder

This builder.

setIsNullable

fun setIsNullable(isNullable: Boolean): NavArgument.Builder

Specify if the argument is nullable. The NavType you set for this argument must allow nullable values.

Parameters
isNullable: Boolean

Argument will be nullable if true.

Returns
NavArgument.Builder

This builder.

setType

fun <T : Any?> setType(type: NavType<T>): NavArgument.Builder

Set the type of the argument.

Parameters
type: NavType<T>

Type of the argument.

Returns
NavArgument.Builder

This builder.