UserResponse class
This class represents the response entity of the User API in the Duolingo API.
This entity contains information such as the authenticated user's lingot and XP, as well as information about the courses they have studied and their skills.
Example:
void main() async {
final duolingo = Duolingo.instance;
final authResponse = await duolingo.authenticate(
username: 'test_username',
password: 'test_password',
);
final userResponse = await duolingo.user(userId: authResponse.userId);
print(userResponse.name);
print(userResponse.lingots);
for (final course in userResponse.courses) {
print(course.title);
print(course.xp);
}
// Skill information is stored in a hierarchical structure.
final skillBook = userResponse.currentCourse.skillBook;
for (final chapter in skillBook.chapters) {
for (final content in chapter.contents) {
if (content.isAccessible) {
print(content.name);
print(content.proficiency);
print(content.tipsAndNotes);
}
}
}
// If you don't like the nested structure,
// you can use the toFlat method to make the structure flat.
//
// If you use the toFlat method, all the skill information that
// exists in SkillBook will be returned as a new list.
for (final skill in skillBook.toFlat()) {
if (skill.isAccessible) {
print(skill.name);
print(skill.proficiency);
print(skill.tipsAndNotes);
}
}
}
Constructors
-
UserResponse.from({required int statusCode, required String reasonPhrase, required Map<
String, String> headers, required String id, required String username, required String name, required String biography, required String profileCountry, required String email, required bool isVerifiedEmail, required String pictureUrl, required String timezone, required String timezoneOffset, required String motivation, required String inviteUrl, required String fromLanguage, required String learningLanguage, required TrackingProperty trackingProperty, required XpConfiguration xpConfiguration, required GemsConfiguration gemsConfiguration, required List<Course> courses, required CurrentCourse currentCourse, required LastStreak lastStreak, required bool xpGoalMetToday, required int xpGoal, required int weeklyXp, required int monthlyXp, required int totalXp, required int lingots, required int gems, required String currentCourseId, required String coachOutfit, required int streak, required int longestStreak, required String plusStatus, required bool hasPlus, required List<PracticeReminderSetting> practiceReminderSettings, required DateTime createdAt}) - Returns the new instance of UserResponse based on arguments.
Properties
- biography → String
-
The biography
final
- coachOutfit → String
-
The coach outfit
final
-
courses
→ List<
Course> -
The courses
final
- createdAt → DateTime
-
The created datetime
final
- currentCourse → CurrentCourse
-
The current course
final
- currentCourseId → String
-
The current course id
final
- email → String
-
The email
final
- fromLanguage → String
-
The from language
final
- gems → int
-
The gems
final
- gemsConfiguration → GemsConfiguration
-
The gems configuration
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- hasPlus → bool
-
The flag that represents user has plus status or not
final
-
headers
→ Map<
String, String> -
The http headers
finalinherited
- id → String
-
The id
final
- inviteUrl → String
-
The invite url
final
- isVerifiedEmail → bool
-
The flag that represents email is verified or not
final
- lastStreak → LastStreak
-
The last streak
final
- learningLanguage → String
-
The learning language
final
- lingots → int
-
The lingots
final
- longestStreak → int
-
The longest streak
final
- monthlyXp → int
-
The monthly xp
final
- motivation → String
-
The motivation
final
- name → String
-
The name
final
- pictureUrl → String
-
The picture url
final
- plusStatus → String
-
The plus status
final
-
practiceReminderSettings
→ List<
PracticeReminderSetting> -
The practice reminder settings
final
- profileCountry → String
-
The profile country
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- status → Status
-
The http status
finalinherited
- streak → int
-
The streak
final
- timezone → String
-
The timezone
final
- timezoneOffset → String
-
The offset of timezone
final
- totalXp → int
-
The total xp
final
- trackingProperty → TrackingProperty
-
The tracking property
final
- username → String
-
The username
final
- weeklyXp → int
-
The weekly xp
final
- xpConfiguration → XpConfiguration
-
The XP configuration
final
- xpGoal → int
-
The xp goal
final
- xpGoalMetToday → bool
-
The flag that represents xp goal met today or not
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override