position static method

int? position(
  1. String haystack,
  2. String needle, {
  3. int offset = 0,
})

Returns the index of the first occurrence of needle in haystack, or null if not found. offset starts the search from a position.

Implementation

static int? position(String haystack, String needle, {int offset = 0}) {
  if (needle.isEmpty) return null;
  final index = haystack.indexOf(needle, offset);
  return index == -1 ? null : index;
}