The Android Developer Challenge is back! Submit your idea before December 2.

Builder

class Builder
kotlin.Any
   ↳ androidx.navigation.NavArgument.Builder

A builder for constructing NavArgument instances.

Summary

Public constructors

A builder for constructing NavArgument instances.

Public methods

NavArgument

Build the NavArgument specified by this builder.

NavArgument.Builder
setDefaultValue(@Nullable defaultValue: Any?)

Specify the default value for an argument.

NavArgument.Builder
setIsNullable(isNullable: Boolean)

Specify if the argument is nullable.

NavArgument.Builder
setType(@NonNull type: NavType<*>)

Set the type of the argument.

Public constructors

<init>

Builder()

A builder for constructing NavArgument instances.

Public methods

build

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

Return
NavArgument: the newly constructed NavArgument.

setDefaultValue

@NonNull fun setDefaultValue(@Nullable 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.
Return
NavArgument.Builder: This builder.

setIsNullable

@NonNull 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.
Return
NavArgument.Builder: This builder.

setType

@NonNull fun setType(@NonNull type: NavType<*>): NavArgument.Builder

Set the type of the argument.

Parameters
type NavType<*>: Type of the argument.
Return
NavArgument.Builder: This builder.