# NavArgument

Artifact: [androidx.navigation:navigation-common](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/NavArgument.kt+class:androidx.navigation.NavArgument) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0)

*** ** * ** ***


```
public final class NavArgument
```

<br />

*** ** * ** ***

NavArgument denotes an argument that is supported by a `https://developer.android.com/reference/androidx/navigation/NavDestination`.

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

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/navigation/NavArgument.Builder` A builder for constructing `https://developer.android.com/reference/androidx/navigation/NavArgument` instances. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/navigation/NavArgument#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/navigation/NavArgument#getDefaultValue()()` The default value of this argument or `null` if it doesn't have a default value. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavType<https://developer.android.com/reference/java/lang/Object.html>` | `https://developer.android.com/reference/androidx/navigation/NavArgument#getType()()` The type of this NavArgument. |
| `int` | `https://developer.android.com/reference/androidx/navigation/NavArgument#hashCode()()` |
| `final boolean` | `https://developer.android.com/reference/androidx/navigation/NavArgument#isDefaultValuePresent()()` Used to distinguish between a default value of `null` and an argument without an explicit default value. |
| `final boolean` | `https://developer.android.com/reference/androidx/navigation/NavArgument#isNullable()()` Whether this argument allows passing a `null` value. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/navigation/NavArgument#toString()()` |

## Public methods

### equals

```
public boolean equals(Object other)
```

### getDefaultValue

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0)

```
public final Object getDefaultValue()
```

The default value of this argument or `null` if it doesn't have a default value. Use `https://developer.android.com/reference/androidx/navigation/NavArgument#isDefaultValuePresent()` to distinguish between `null` and absence of a value.

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html` | The default value assigned to this argument. |

### getType

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0)

```
public final @NonNull NavType<Object> getType()
```

The type of this NavArgument.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavType<https://developer.android.com/reference/java/lang/Object.html>` | the NavType object denoting the type that can be help in this argument. |

### hashCode

```
public int hashCode()
```

### isDefaultValuePresent

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0)

```
public final boolean isDefaultValuePresent()
```

Used to distinguish between a default value of `null` and an argument without an explicit default value.

| Returns |
|---|---|
| `boolean` | true if this argument has a default value (even if that value is set to null), false otherwise |

### isNullable

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0)

```
public final boolean isNullable()
```

Whether this argument allows passing a `null` value.

| Returns |
|---|---|
| `boolean` | true if `null` is allowed, false otherwise |

### toString

```
public @NonNull String toString()
```