# ExpandableStateMapping

# ExpandableStateMapping

Artifact:[androidx.wear.compose:compose-foundation](https://developer.android.com/jetpack/androidx/releases/wear-compose)  
[View Source](https://cs.android.com/search?q=file:androidx/wear/compose/foundation/Expandable.kt+class:androidx.wear.compose.foundation.ExpandableStateMapping)  
Added in[1.4.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.4.0)

<br />

```
@ExperimentalWearFoundationApi
class ExpandableStateMapping<T : Any?>
```

<br />

*** ** * ** ***

A class that maps from keys of the given type to[ExpandableState](https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/ExpandableState). An instance can be created and remembered with[rememberExpandableStateMapping](https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/package-summary#rememberExpandableStateMapping(kotlin.Function1,androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec))

## Summary

|                                                ### Public functions                                                |
|--------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ExpandableState](https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/ExpandableState) | [getOrPutNew](https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/ExpandableStateMapping#getOrPutNew(kotlin.Any))`(key: T)` Returns the[ExpandableState](https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/ExpandableState)for the given key if the value is present and not null. |

## Public functions

### getOrPutNew

Added in[1.4.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.4.0)  

```
fun getOrPutNew(key: T): ExpandableState
```

Returns the[ExpandableState](https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/ExpandableState)for the given key if the value is present and not null. Otherwise, creates a new one, puts it into the map under the given key and returns it. The parameters used to create the new[ExpandableState](https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/ExpandableState)are the ones passed to[rememberExpandableStateMapping](https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/package-summary#rememberExpandableStateMapping(kotlin.Function1,androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec))