---
title: "SnapshotStateList"
description: "An implementation of [MutableList] that can be observed and snapshot. This is the result type
created by [androidx.compose.runtime.mutableStateListOf].

This class closely implements the same semantics as [ArrayList]."
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-nonAndroid'>NonAndroid</div>


```kotlin
public actual class SnapshotStateList<T>
internal actual constructor(persistentList: PersistentList<T>) :
    StateObject, MutableList<T>, RandomAccess
```


An implementation of `MutableList` that can be observed and snapshot. This is the result type
created by `androidx.compose.runtime.mutableStateListOf`.

This class closely implements the same semantics as `ArrayList`.


## Secondary Constructors

```kotlin
public actual constructor() : this(persistentListOf())
```

## Functions

```kotlin
public actual fun toList(): List<T>
```


Return a list containing all the elements of this list.

The list returned is immutable and returned will not change even if the content of the list
is changed in the same snapshot. It also will be the same instance until the content is
changed. It is not, however, guaranteed to be the same instance for the same list as adding
and removing the same item from the this list might produce a different instance with the
same content.

This operation is O(1) and does not involve a physically copying the list. It instead returns
the underlying immutable list used internally to store the content of the list.

It is recommended to use `toList` when using returning the value of this list from
`androidx.compose.runtime.snapshotFlow`.


```kotlin
public actual fun removeRange(fromIndex: Int, toIndex: Int)
```

<div class='sourceset sourceset-common'>Common</div>


```kotlin
public expect class SnapshotStateList<T> internal constructor(persistentList: PersistentList<T>) :
    StateObject, MutableList<T>, RandomAccess
```


An implementation of `MutableList` that can be observed and snapshot. This is the result type
created by `androidx.compose.runtime.mutableStateListOf`.

This class closely implements the same semantics as `ArrayList`.


## Secondary Constructors

```kotlin
public constructor()
```

## Functions

```kotlin
public fun toList(): List<T>
```


Return a list containing all the elements of this list.

The list returned is immutable and returned will not change even if the content of the list
is changed in the same snapshot. It also will be the same instance until the content is
changed. It is not, however, guaranteed to be the same instance for the same list as adding
and removing the same item from the this list might produce a different instance with the
same content.

This operation is O(1) and does not involve a physically copying the list. It instead returns
the underlying immutable list used internally to store the content of the list.

It is recommended to use `toList` when using returning the value of this list from
`androidx.compose.runtime.snapshotFlow`.


```kotlin
public fun removeRange(fromIndex: Int, toIndex: Int)
```

<div class='sourceset sourceset-android'>Android</div>


```kotlin
@SuppressLint("BanParcelableUsage")
public actual class SnapshotStateList<T>
internal actual constructor(persistentList: PersistentList<T>) :
    Parcelable, StateObject, MutableList<T>, RandomAccess
```


An implementation of `MutableList` that can be observed and snapshot. This is the result type
created by `androidx.compose.runtime.mutableStateListOf`.

This class closely implements the same semantics as `ArrayList`.


## Secondary Constructors

```kotlin
public actual constructor() : this(persistentListOf())
```

## Functions

```kotlin
public actual fun toList(): List<T>
```


Return a list containing all the elements of this list.

The list returned is immutable and returned will not change even if the content of the list
is changed in the same snapshot. It also will be the same instance until the content is
changed. It is not, however, guaranteed to be the same instance for the same list as adding
and removing the same item from the this list might produce a different instance with the
same content.

This operation is O(1) and does not involve a physically copying the list. It instead returns
the underlying immutable list used internally to store the content of the list.

It is recommended to use `toList` when using returning the value of this list from
`androidx.compose.runtime.snapshotFlow`.


```kotlin
public actual fun removeRange(fromIndex: Int, toIndex: Int)
```

## Companion Object

#### Properties

<div class='sourceset sourceset-android'>Android</div>


```kotlin
@JvmField
    val CREATOR: Parcelable.Creator<SnapshotStateList<Any?>>
```




