Register now for Android Dev Summit 2019!

NavArgument

class NavArgument
kotlin.Any
   ↳ androidx.navigation.NavArgument

NavArgument denotes an argument that is supported by a NavDestination.

A NavArgument has a type and optionally a default value, that are used to read/write it in a Bundle. It can also be nullable if the type supports it.

Summary

Nested classes

A builder for constructing NavArgument instances.

Public methods

Boolean
equals(other: Any?)

Any?

Returns the default value of this argument or `null` if it doesn't have a default value.

NavType<*>

Get the type of this NavArgument.

Int

Boolean

This method can be used to distinguish between a default value of `null` and an argument without an explicit default value.

Boolean

Check if this argument allows passing a `null` value.

Public methods

equals

fun equals(other: Any?): Boolean

getDefaultValue

@Nullable fun getDefaultValue(): Any?

Returns the default value of this argument or `null` if it doesn't have a default value. Use isDefaultValuePresent() to distinguish between `null` and absence of a value.

Return
Any?: The deafult value assigned to this argument.

getType

@NonNull fun getType(): NavType<*>

Get the type of this NavArgument.

Return
NavType<*>: the NavType object denoting the type that can be help in this argument.

hashCode

fun hashCode(): Int

isDefaultValuePresent

fun isDefaultValuePresent(): Boolean

This method can be used to distinguish between a default value of `null` and an argument without an explicit default value.

Return
Boolean: true if this argument has a default value (even if that value is set to null), false otherwise

isNullable

fun isNullable(): Boolean

Check if this argument allows passing a `null` value.

Return
Boolean: true if `null` is allowed, false otherwise