getWordsOfPrefix method

List<String> getWordsOfPrefix(
  1. String prefix
)

Implementation

List<String> getWordsOfPrefix(String prefix) {
  //returns a list of words of a particular prefix from the tokens minus the prefix [case insensitive]
  List<String> result = [];

  for (var i = 0; i < lines.length; i++) {
    if (lines[i].toUpperCase().startsWith(prefix.toUpperCase())) {
      String word = lines[i];
      word = word.substring(prefix.length, word.length);
      result.add(word);
    }
  }
  return result;
}