# UndoState

# UndoState

Artifact:[androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation)  
[View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/text/input/UndoState.kt+class:androidx.compose.foundation.text.input.UndoState)  
Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.7.0)
Common/All
  - Cmn  

  ```
  class UndoState
  ```

*** ** * ** ***

Defines an interactable undo history.

## Summary

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [clearHistory](https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/input/UndoState#clearHistory())`()` Clears all undo and redo history up to this point.                                                                                                  | Cmn |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [redo](https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/input/UndoState#redo())`()` Re-applies a change that was previously reverted via[undo](https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/input/UndoState#undo()). | Cmn |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [undo](https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/input/UndoState#undo())`()` Reverts the latest edit action or a group of actions that are merged together.                                                                                      | Cmn |

|                                ### Public properties                                |
|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [canRedo](https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/input/UndoState#canRedo()) Whether it is possible to execute a meaningful redo action right now. | Cmn |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [canUndo](https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/input/UndoState#canUndo()) Whether it is possible to execute a meaningful undo action right now. | Cmn |

## Public functions

### clearHistory

Cmn  
Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.7.0)  

```
fun clearHistory(): Unit
```

Clears all undo and redo history up to this point.  

### redo

Cmn  
Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.7.0)  

```
fun redo(): Unit
```

Re-applies a change that was previously reverted via[undo](https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/input/UndoState#undo()).  

### undo

Cmn  
Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.7.0)  

```
fun undo(): Unit
```

Reverts the latest edit action or a group of actions that are merged together. Calling it repeatedly can continue undoing the previous actions.

## Public properties

### canRedo

Cmn  
Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.7.0)  

```
val canRedo: Boolean
```

Whether it is possible to execute a meaningful redo action right now. If this value is false, calling`redo`would be a no-op.  

### canUndo

Cmn  
Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.7.0)  

```
val canUndo: Boolean
```

Whether it is possible to execute a meaningful undo action right now. If this value is false, calling`undo`would be a no-op.