---
title: "ExpandPolicy"
description: "Defines how a TrackedRange expands when text is inserted exactly at its boundaries."
type: "class"
lastmod: "2026-05-20T01:13:53.302418Z"
---
## API Reference

> Source set: Common

```kotlin
value class ExpandPolicy private constructor(private val flag: Int)
```

Defines how a [TrackedRange](/jetpack-compose/androidx.compose.foundation/foundation/classes/TrackedRange) expands when text is inserted exactly at its boundaries.

This policy is used in methods like [TextFieldBuffer.addStyle](/jetpack-compose/androidx.compose.foundation/foundation/classes/TextFieldBuffer) to configure whether the range
expands to include text inserted at its start, end, or both boundaries.

## Secondary Constructors

```kotlin
internal constructor(
    startExpands: Boolean,
    endExpands: Boolean,
) : this(
    (if (startExpands) FLAG_EXPAND_START else 0) or (if (endExpands) FLAG_EXPAND_END else 0)
)
```

## Companion Object

#### Properties

> Source set: Common

```kotlin
val InsideOnly = ExpandPolicy(0b0000)
```

The range will not expand when text is inserted at its boundaries. Text inserted exactly
at the start or end will be placed outside the range.

> Source set: Common

```kotlin
val AtStart = ExpandPolicy(FLAG_EXPAND_START)
```

The range will expand when text is inserted at its start boundary. Text inserted exactly
at the start will be included in the range.

> Source set: Common

```kotlin
val AtEnd = ExpandPolicy(FLAG_EXPAND_END)
```

The range will expand when text is inserted at its end boundary. Text inserted exactly at
the end will be included in the range.

> Source set: Common

```kotlin
val AtBoth = ExpandPolicy(FLAG_EXPAND_START or FLAG_EXPAND_END)
```

The range will expand when text is inserted at either of its boundaries.
