indexOf method

int? indexOf(
  1. Pattern pattern, [
  2. int start = 0
])

Returns the position of the first match of pattern in this string, starting at start, inclusive:

const string = 'Dartisans';
print(string.indexOf('art')); // 1
print(string.indexOf(RegExp(r'[A-Z][a-z]'))); // 0

Returns -1 if no match is found:

const string = 'Dartisans';
string.indexOf(RegExp(r'dart')); // -1

The start must be non-negative and not greater than length.

Implementation

int? indexOf(Pattern pattern, [int start = 0]) =>
    value?.indexOf(pattern, start);