NavArgument.Builder

class NavArgument.Builder


A builder for constructing NavArgument instances.

Summary

Public constructors

Public functions

NavArgument

Build the NavArgument specified by this builder.

NavArgument.Builder
setDefaultValue(defaultValue: Any?)

Specify the default value for an argument.

NavArgument.Builder
setIsNullable(isNullable: Boolean)

Specify if the argument is nullable.

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

Set the type of the argument.

Public constructors

Builder

Added in 1.0.0
Builder()

Public functions

build

Added in 1.0.0
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

Added in 1.0.0
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

Added in 1.0.0
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

Added in 2.4.0
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.