fromJson static method
Returns a new CharacterLeaderboardSchema instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static CharacterLeaderboardSchema? 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(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key), 'Required key "CharacterLeaderboardSchema[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "CharacterLeaderboardSchema[$key]" has a null value in JSON.');
});
return true;
}());
return CharacterLeaderboardSchema(
position: mapValueOfType<int>(json, r'position')!,
name: mapValueOfType<String>(json, r'name')!,
account: mapValueOfType<String>(json, r'account')!,
skin: mapValueOfType<String>(json, r'skin')!,
level: mapValueOfType<int>(json, r'level')!,
totalXp: mapValueOfType<int>(json, r'total_xp')!,
miningLevel: mapValueOfType<int>(json, r'mining_level')!,
miningTotalXp: mapValueOfType<int>(json, r'mining_total_xp')!,
woodcuttingLevel: mapValueOfType<int>(json, r'woodcutting_level')!,
woodcuttingTotalXp: mapValueOfType<int>(json, r'woodcutting_total_xp')!,
fishingLevel: mapValueOfType<int>(json, r'fishing_level')!,
fishingTotalXp: mapValueOfType<int>(json, r'fishing_total_xp')!,
weaponcraftingLevel: mapValueOfType<int>(json, r'weaponcrafting_level')!,
weaponcraftingTotalXp: mapValueOfType<int>(json, r'weaponcrafting_total_xp')!,
gearcraftingLevel: mapValueOfType<int>(json, r'gearcrafting_level')!,
gearcraftingTotalXp: mapValueOfType<int>(json, r'gearcrafting_total_xp')!,
jewelrycraftingLevel: mapValueOfType<int>(json, r'jewelrycrafting_level')!,
jewelrycraftingTotalXp: mapValueOfType<int>(json, r'jewelrycrafting_total_xp')!,
cookingLevel: mapValueOfType<int>(json, r'cooking_level')!,
cookingTotalXp: mapValueOfType<int>(json, r'cooking_total_xp')!,
alchemyLevel: mapValueOfType<int>(json, r'alchemy_level')!,
alchemyTotalXp: mapValueOfType<int>(json, r'alchemy_total_xp')!,
gold: mapValueOfType<int>(json, r'gold')!,
);
}
return null;
}