fromJson static method
Returns a new AccountAchievementSchema instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static AccountAchievementSchema? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
assert(json.containsKey(r'name'),
'Required key "AccountAchievementSchema[name]" is missing from JSON.');
assert(json[r'name'] != null,
'Required key "AccountAchievementSchema[name]" has a null value in JSON.');
assert(json.containsKey(r'code'),
'Required key "AccountAchievementSchema[code]" is missing from JSON.');
assert(json[r'code'] != null,
'Required key "AccountAchievementSchema[code]" has a null value in JSON.');
assert(json.containsKey(r'description'),
'Required key "AccountAchievementSchema[description]" is missing from JSON.');
assert(json[r'description'] != null,
'Required key "AccountAchievementSchema[description]" has a null value in JSON.');
assert(json.containsKey(r'points'),
'Required key "AccountAchievementSchema[points]" is missing from JSON.');
assert(json[r'points'] != null,
'Required key "AccountAchievementSchema[points]" has a null value in JSON.');
assert(json.containsKey(r'objectives'),
'Required key "AccountAchievementSchema[objectives]" is missing from JSON.');
assert(json[r'objectives'] != null,
'Required key "AccountAchievementSchema[objectives]" has a null value in JSON.');
assert(json.containsKey(r'rewards'),
'Required key "AccountAchievementSchema[rewards]" is missing from JSON.');
assert(json[r'rewards'] != null,
'Required key "AccountAchievementSchema[rewards]" has a null value in JSON.');
return true;
}());
return AccountAchievementSchema(
name: mapValueOfType<String>(json, r'name')!,
code: mapValueOfType<String>(json, r'code')!,
description: mapValueOfType<String>(json, r'description')!,
points: mapValueOfType<int>(json, r'points')!,
objectives:
AccountAchievementObjectiveSchema.listFromJson(json[r'objectives']),
rewards: AchievementRewardsSchema.fromJson(json[r'rewards'])!,
completedAt: mapDateTime(json, r'completed_at', r''),
);
}
return null;
}