fromJson static method
Returns a new FakeCharacterSchema instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static FakeCharacterSchema? 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 "FakeCharacterSchema[$key]" is missing from JSON.');
assert(json[key] != null,
'Required key "FakeCharacterSchema[$key]" has a null value in JSON.');
});
return true;
}());
return FakeCharacterSchema(
level: mapValueOfType<int>(json, r'level')!,
weaponSlot: mapValueOfType<String>(json, r'weapon_slot'),
runeSlot: mapValueOfType<String>(json, r'rune_slot'),
shieldSlot: mapValueOfType<String>(json, r'shield_slot'),
helmetSlot: mapValueOfType<String>(json, r'helmet_slot'),
bodyArmorSlot: mapValueOfType<String>(json, r'body_armor_slot'),
legArmorSlot: mapValueOfType<String>(json, r'leg_armor_slot'),
bootsSlot: mapValueOfType<String>(json, r'boots_slot'),
ring1Slot: mapValueOfType<String>(json, r'ring1_slot'),
ring2Slot: mapValueOfType<String>(json, r'ring2_slot'),
amuletSlot: mapValueOfType<String>(json, r'amulet_slot'),
artifact1Slot: mapValueOfType<String>(json, r'artifact1_slot'),
artifact2Slot: mapValueOfType<String>(json, r'artifact2_slot'),
artifact3Slot: mapValueOfType<String>(json, r'artifact3_slot'),
utility1Slot: mapValueOfType<String>(json, r'utility1_slot'),
utility1SlotQuantity:
mapValueOfType<int>(json, r'utility1_slot_quantity') ?? 1,
utility2Slot: mapValueOfType<String>(json, r'utility2_slot'),
utility2SlotQuantity:
mapValueOfType<int>(json, r'utility2_slot_quantity') ?? 1,
);
}
return null;
}