---
title: "TextRange"
description: "An immutable text range class, represents a text range from [start] (inclusive) to [end]
(exclusive). [end] can be smaller than [start] and in those cases [min] and [max] can be used in
order to fetch the values."
type: "function"
---

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


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun TextRange(/*@IntRange(from = 0)*/ start: Int, /*@IntRange(from = 0)*/ end: Int) =
    TextRange(packWithCheck(start, end))
```


An immutable text range class, represents a text range from `start` (inclusive) to `end`
(exclusive). `end` can be smaller than `start` and in those cases `min` and `max` can be used in
order to fetch the values.

#### Parameters

| | |
| --- | --- |
| start | the inclusive start offset of the range. Must be non-negative, otherwise an exception will be thrown. |
| end | the exclusive end offset of the range. Must be non-negative, otherwise an exception will be thrown. |




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


```kotlin
fun TextRange(index: Int): TextRange
```


Creates a `TextRange` where start is equal to end, and the value of those are `index`.



