cachedDictionary abstract method

Future<DictionaryResponse> cachedDictionary({
  1. required String wordId,
})

Returns cached dictionary information linked to wordId.

From this API, you can refer to the information on the official Duolingo page at the following URL: https://www.duolingo.com/dictionary/Japanese/%E6%95%B0%E5%AD%A6/00a6288128ad4e286a35078ded5ffde9

The first call to this cachedDictionary method will always result in a communication with the Duolingo API because there is no cached DictionaryResponse. In the second and subsequent method calls, the cached DictionaryResponse from the first method call will be returned.

The type and data structure of the response is consistent with the dictionary method. However, please note that the cached data is returned from this method, so unless you explicitly delete this cached object data, the cached response object will always be returned.

To delete the explicitly cached DictionaryResponse, call the cleanCachedDictionary method.

Example:

void main() async {
 final duolingo = Duolingo.instance;

 final authResponse = await duolingo.authenticate(
   username: 'test_username',
   password: 'test_password',
 );

 final dictionaryResponse = await duolingo.cachedDictionary(
   wordId: 'cbdb71cdcf9e4715771206e1c0b0b94c',
 );

 print(dictionaryResponse);

 for (final alternativeForm in dictionaryResponse.alternativeForms) {
   print(alternativeForm);
 }

 for (final discussion in dictionaryResponse.relatedDiscussions) {
   print(discussion);
 }

 for (final lexeme in dictionaryResponse.relatedLexemes) {
   print(lexeme);
 }
}

Implementation

Future<DictionaryResponse> cachedDictionary({
  required String wordId,
});