coerceIn

Function

Common
fun TextRange.coerceIn(minimumValue: Int, maximumValue: Int): TextRange

Ensures that TextRange.start and TextRange.end values lies in the specified range minimumValue and maximumValue. For each TextRange.start and TextRange.end values:

  • if value is smaller than minimumValue, value is replaced by minimumValue
  • if value is greater than maximumValue, value is replaced by maximumValue

Parameters

minimumValuethe minimum value that TextRange.start or TextRange.end can be.
maximumValuethe exclusive maximum value that TextRange.start or TextRange.end can be.