insert method

void insert(
  1. String word,
  2. T value
)

Inserts the word into the trie.

Implementation

void insert(String word, T value) {
  var currentNode = _root;

  for (final character in word.characters) {
    currentNode = currentNode.putChildIfAbsent(character);
  }

  currentNode.isEndOfWord = true;

  // The last character of the word stores the associated word value.
  currentNode.value = value;
}