WordHintResponse class
This class represents the Word Hint API response entity in the Duolingo API.
In this entity object, the Word Hint API decomposes the word or sentence parameters that are set when sending a request to the Duolingo API into the smallest units that are meaningful as words, and manages the data as HintToken. And so in this entity object, tokens, which is a set of HintToken, is set.
Each HintToken contains the word or words to be parsed for that token unit. as well as the hint information associated with the word for that token unit.
For the overall data structure of this entity object please refer to following JSON samples.
Example:
void main() async {
final duolingo = Duolingo.instance;
final wordHintResponse = await duolingo.wordHint(
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);
}
}
}
// If you don't like the complex structure described above,
// you can convert it to a simpler structure.
print(wordHintResponse.prettify());
}
Constructors
-
WordHintResponse.from({required int statusCode, required String reasonPhrase, required Map<
String, String> headers, required List<HintToken> tokens}) - Returns the new instance of WordHintResponse based on arguments.
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
-
headers
→ Map<
String, String> -
The http headers
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- status → Status
-
The http status
finalinherited
-
tokens
→ List<
HintToken> -
The hint tokens
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prettify(
) → Map< String, List< String> > - Return this hint table as a simpler structure.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override