secondIndex method

  1. @useResult
int secondIndex(
  1. String char
)

Returns the index of the second occurrence of char, or -1 if not found.

Implementation

@useResult
int secondIndex(String char) {
  if (char.isEmpty || isEmpty) {
    return -1;
  }

  final int firstIdx = indexOf(char);
  if (firstIdx == -1) {
    return -1;
  }

  return indexOf(char, firstIdx + 1);
}