Word Puzzle Pack
A Flutter package for English words with utilities for word games and puzzles.
Features
- Word Utilities: Anagram detection, palindrome checking, word scoring, letter frequency analysis
- Word Validation: Check if words are valid English words, contain only letters, vowel/consonant counting
- Word Lists: Curated lists of 1200+ common English words
- Dictionary: Complete dictionary with meanings, examples, synonyms, and acronyms
- Puzzle Tools: Find words by length, search for anagrams, and more
Installation
Add this to your package's pubspec.yaml file:
dependencies:
word_puzzle_pack: ^0.1.0
Then run:
flutter pub get
Usage
import 'package:word_puzzle_pack/word_puzzle_pack.dart';
// Load dictionary data
DictionaryData.loadDefaultEntries();
// Dictionary lookup
DictionaryEntry? entry = Dictionary.lookup('happy');
print(entry?.meaning); // "Feeling or showing pleasure or contentment"
print(entry?.example); // "She was happy to see her friends."
print(entry?.synonyms); // ["joyful", "cheerful", "glad", "pleased"]
// Search dictionary
List<DictionaryEntry> synonyms = Dictionary.findSynonyms('happy');
List<DictionaryEntry> acronyms = Dictionary.findAcronyms();
List<DictionaryEntry> wordsWithMeaning = Dictionary.searchByMeaning('pleasure');
// Word utilities
bool isAnagram = WordUtils.isAnagram('listen', 'silent'); // true
bool isPalindrome = WordUtils.isPalindrome('racecar'); // true
int score = WordUtils.getWordScore('quiz'); // 22
// Word validation
bool isValid = WordValidator.isValidEnglishWord('hello'); // true
int vowelCount = WordValidator.countVowels('hello'); // 2
// Work with word lists (1200+ words)
List<String> allWords = WordLists.getAllWords();
List<String> threeLetterWords = WordLists.getWordsByLength(3);
// Advanced word filtering with count parameter
List<String> wordsInRange = WordLists.getWordsByLengthRange(3, 6, count: 5);
List<String> randomWords = WordLists.getRandomWords(count: 10);
List<String> longWords = WordLists.getWordsByMinLength(8, count: 3);
List<String> shortWords = WordLists.getWordsByMaxLength(4, count: 5);
// Pattern-based filtering
List<String> wordsStartingWithTh = WordLists.getWordsStartingWith('th', count: 3);
List<String> wordsEndingWithIng = WordLists.getWordsEndingWith('ing', count: 5);
List<String> wordsContainingOo = WordLists.getWordsContaining('oo', count: 4);
// Find anagrams from word list
List<String> anagrams = WordUtils.findAnagrams('evil', WordLists.getAllWords());
API Reference
WordUtils
isAnagram(String word1, String word2)- Check if two words are anagramsisPalindrome(String word)- Check if a word is a palindromegetWordScore(String word)- Calculate Scrabble-like score for a wordreverseWord(String word)- Reverse a wordgetLetterFrequency(String word)- Get frequency map of letters in a wordfindAnagrams(String word, List<String> wordList)- Find anagrams in a word listfindWordsOfLength(int length, List<String> wordList)- Find words of specific length
WordValidator
isValidEnglishWord(String word)- Check if word contains only letterscontainsOnlyLetters(String word)- Check if word contains only letterscountVowels(String word)- Count vowels in a wordcountConsonants(String word)- Count consonants in a wordhasMinimumLength(String word, int minLength)- Check minimum lengthhasMaximumLength(String word, int maxLength)- Check maximum length
WordLists
getAllWords()- Get all available words (1200+ words)getWordsByLength(int length)- Get words of specific lengthgetWordsByLengthRange(int minLength, int maxLength, {int count = 1})- Get words within length rangegetRandomWords({int count = 1})- Get random wordsgetWordsByMinLength(int minLength, {int count = 1})- Get words with minimum lengthgetWordsByMaxLength(int maxLength, {int count = 1})- Get words with maximum lengthgetWordsStartingWith(String prefix, {int count = 1})- Get words starting with prefixgetWordsEndingWith(String suffix, {int count = 1})- Get words ending with suffixgetWordsContaining(String substring, {int count = 1})- Get words containing substringcommonWords- List of common English words
Dictionary
lookup(String word)- Look up a word in the dictionarycontains(String word)- Check if word exists in dictionarygetAllWords()- Get all dictionary wordsfindByPrefix(String prefix)- Find words starting with prefixfindBySuffix(String suffix)- Find words ending with suffixfindByLength(int length)- Find words of specific lengthsearchByMeaning(String term)- Search by meaning contentfindSynonyms(String word)- Find synonyms for a wordfindAcronyms()- Get all acronym entriesfindByAcronym(String acronym)- Find words by acronym expansionaddEntry(DictionaryEntry entry)- Add custom dictionary entrygetRandomEntries(int count)- Get random dictionary entries
DictionaryEntry
word- The word itselfmeaning- Definition of the wordexample- Example sentence using the wordsynonyms- List of synonymsacronym- Acronym expansion (optional)toMap()- Convert to MapfromMap(Map map)- Create from Map
Example
Check out the example/main.dart file for a complete Flutter app demonstrating the package features.
Testing
Run the tests with:
flutter test
License
MIT License