indexesOf method

List<int> indexesOf(
  1. String charCode, {
  2. bool ignoreCase = false,
})

Returns a list containing all positions of a charCode By default, the case is taken into account. Set ignoreCase to true, to disable the case verification.

Implementation

List<int> indexesOf(String charCode, {bool ignoreCase = false}) {
  assert(charCode.length == 1);
  if (ignoreCase) {
    charCode = charCode.toLowerCase();
  }

  final List<int> positions = <int>[];
  int i = 0;

  for (; i != length; i++) {
    if ((ignoreCase && this[i].toLowerCase() == charCode) ||
        this[i] == charCode) {
      positions.add(i);
    }
  }

  return positions;
}