Flutter Dictionary API
A Flutter package that provides a simple and easy-to-use interface for the Free Dictionary API.
Features
- Get complete word data including definitions, pronunciation, and etymology
- Check if a word exists in the dictionary
- Get specific information about a word:
- Definitions
- Parts of speech
- Pronunciation (text and audio URL)
- Origin/etymology
- Usage examples
- Synonyms
- Antonyms
Installation
Add this to your package's pubspec.yaml
file:
dependencies:
dictionary_api: ^0.1.0
Usage
import 'package:dictionary_api/dictionary_api.dart';
// Get complete word data
final wordData = await DictionaryApi.getWordData('example');
// Check if a word exists
final exists = await DictionaryApi.wordExists('example');
// Get definitions
final definitions = await DictionaryApi.getDefinitions('example');
// Get parts of speech
final partsOfSpeech = await DictionaryApi.getPartsOfSpeech('example');
// Get pronunciation
final pronunciation = await DictionaryApi.getPronunciation('example');
if (pronunciation != null) {
print('Text: ${pronunciation.text}');
print('Audio URL: ${pronunciation.audio}');
}
// Get origin/etymology
final origin = await DictionaryApi.getOrigin('example');
// Get usage examples
final examples = await DictionaryApi.getExamples('example');
// Get synonyms
final synonyms = await DictionaryApi.getSynonyms('example');
// Get antonyms
final antonyms = await DictionaryApi.getAntonyms('example');
API Details
getWordData(String word)
Returns complete WordData
for a word or null
if not found.
wordExists(String word)
Returns true
if the word exists in the dictionary, false
otherwise.
getDefinitions(String word)
Returns a list of all definitions for the word.
getPartsOfSpeech(String word)
Returns a list of parts of speech for the word (e.g., "noun", "verb").
getPronunciation(String word)
Returns a Pronunciation
object with phonetic text and audio URL.
getOrigin(String word)
Returns the word's origin/etymology or null
if not available.
getExamples(String word)
Returns a list of example sentences using the word.
getSynonyms(String word)
Returns a list of synonyms for the word.
getAntonyms(String word)
Returns a list of antonyms for the word.
Data Models
The package includes several data models:
WordData
: Complete data for a wordMeaning
: A specific meaning of a wordDefinition
: A definition within a meaningPhonetic
: Pronunciation informationPronunciation
: Simplified pronunciation data with text and audio
Dependencies
http
: For making API requestsdart:convert
: For JSON parsing
Credits
This package uses the free Dictionary API service.
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.