cachedWordHint abstract method

Future<WordHintResponse> cachedWordHint({
  1. String fromLanguage,
  2. String learningLanguage,
  3. required String sentence,
})

Returns cached hint information of sentence specified in the argument.

For fromLanguage, specify the language of the hint information, and for learningLanguage, specify the language of the word or sentence specified in sentence.

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

The type and data structure of the response is consistent with the wordHint 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 WordHintResponse, call the cleanCachedWordHint method.

Example:

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

 final wordHintResponse = await duolingo.cachedWordHint(
   fromLanguage: 'en',
   learningLanguage: 'es',
   sentence: 'boligrafos',
 );

 for (final token in wordHintResponse.tokens) {
   final headers = token.table.headers;
   for (final header in headers) {
     print(header.selected);
     print(header.token);
   }

   final rows = token.table.rows;
   for (final row in rows) {
     for (final cell in row.cells) {
       print(cell.hint);
     }
   }
 }

 // Delete cache.
 duolingo.cleanCachedWordHint();
}

Implementation

Future<WordHintResponse> cachedWordHint({
  String fromLanguage,
  String learningLanguage,
  required String sentence,
});