# SavedStateHandle.Companion

Artifact: [androidx.lifecycle:lifecycle-viewmodel-savedstate](https://developer.android.com/jetpack/androidx/releases/lifecycle) [View Source](https://cs.android.com/search?q=file:androidx/lifecycle/SavedStateHandle.+class:androidx.lifecycle.SavedStateHandle.Companion) Added in [2.5.0](https://developer.android.com/jetpack/androidx/releases/lifecycle#2.5.0)

*** ** * ** ***

Common/AllAndroid/JVM
- Cmn

  ```
  object SavedStateHandle.Companion
  ```

*** ** * ** ***

## Summary

| ### Extension functions |
|---|---|---|
| `operator https://developer.android.com/reference/kotlin/androidx/lifecycle/SavedStateHandle` | `https://developer.android.com/reference/kotlin/androidx/lifecycle/SavedStateHandle.Companion.https://developer.android.com/reference/kotlin/androidx/lifecycle/SavedStateHandle.Companion#(androidx.lifecycle.SavedStateHandle.Companion).invoke(kotlin.Any,kotlin.collections.Map)( route: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html, typeMap: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-type/index.html, https://developer.android.com/reference/kotlin/androidx/navigation/NavType<*>> )` SavedStateHandle constructor to create a SavedStateHandle with a serializable object. | Cmn |

## Extension functions

### SavedStateHandle.Companion.invoke

Cmn Artifact: [androidx.navigation:navigation-testing](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/testing/SavedStateHandleFactory.kt+function:invoke)

```
operator fun SavedStateHandle.Companion.invoke(
    route: Any,
    typeMap: Map<KType, NavType<*>> = emptyMap()
): SavedStateHandle
```

SavedStateHandle constructor to create a SavedStateHandle with a serializable object.

Returns a `https://developer.android.com/reference/kotlin/androidx/lifecycle/SavedStateHandle` populated with arguments from `https://developer.android.com/reference/kotlin/androidx/navigation/testing/package-summary#(androidx.lifecycle.SavedStateHandle.Companion).invoke(kotlin.Any,kotlin.collections.Map)`.

Note: To use this api in non-instrumented tests, run with robolectric. This is because android's [Bundle](https://developer.android.com/reference/android/os/Bundle) is necessarily integrated into the parsing of route arguments.

| Parameters |
|---|---|
| `route: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html` | The route to extract argument values from |
| `typeMap: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-type/index.html, https://developer.android.com/reference/kotlin/androidx/navigation/NavType<*>> = emptyMap()` | A mapping of KType to custom NavType\<\*\> in the `https://developer.android.com/reference/kotlin/androidx/navigation/testing/package-summary#(androidx.lifecycle.SavedStateHandle.Companion).invoke(kotlin.Any,kotlin.collections.Map)`. May be empty if `https://developer.android.com/reference/kotlin/androidx/navigation/testing/package-summary#(androidx.lifecycle.SavedStateHandle.Companion).invoke(kotlin.Any,kotlin.collections.Map)` does not use custom NavTypes. |