Skip to content

TextRange

@Immutable



data class TextRange(val start: Int, val end: Int = start)

Represents a half-open character range [start, end) within a text field's content string.

When start == end the range is collapsed and represents a cursor position rather than a selection. start and end may be in either order; min and max always give the canonical inclusive/exclusive bounds regardless of direction.

Constructors

TextRange

constructor(start: Int, end: Int = start)

Types

Companion

object Companion

Properties

end

val end: Int

isCollapsed

true when start and end are equal (cursor, no selection).

length

val length: Int

The number of characters in the selected range.

max

val max: Int

The larger of start and end — exclusive end of the selected region.

min

val min: Int

The smaller of start and end — inclusive start of the selected region.

start

val start: Int

Functions

toString

open override fun toString(): String