matches method

List<Match> matches(
  1. String input
)

returns all matches found. If none were found it returns []

Implementation

List<Match> matches(String input) {
  final fullInput = separateBySpaces ? ' $input ' : input;
  final state = stateMachine.createState();
  final results = <Match>[];
  var smallestStartIndex = fullInput.length;
  for (var i = 0; i < fullInput.length; i++) {
    state.performStep(fullInput[i]);
    if (state.activeStateIsSuccess) {
      results.addAll(state.activeState.words.map((word) {
        smallestStartIndex = min(smallestStartIndex, i - word.length + 1);
        return _fixShiftedMatch(
            Match(startIndex: i - word.length + 1, word: word));
      }).whereNotNull());
    }
  }
  return results;
}