anagram method

Set<String> anagram(
  1. String word, {
  2. bool expand = false,
  3. bool sort = false,
  4. int minLength = 2,
})

Get all legal anagrams of a string, perhaps includng the wildcard '?'.

If expand is true then wildcards are expanded. If sort is true then results are sorted into alphabetical order. If minLength is >2 then only matches of at least that length are returned.

Implementation

Set<String> anagram(String word,
    {bool expand = false, bool sort = false, int minLength = 2}) {
  var anagrams = <String>{};
  _anagramWord(anagrams, '', word, expand, minLength);
  if (sort) {
    return SplayTreeSet.from(anagrams);
  }
  return anagrams;
}