fromJson static method
Returns a new RaidInstanceSchema instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static RaidInstanceSchema? 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'starts_at'),
'Required key "RaidInstanceSchema[starts_at]" is missing from JSON.');
assert(json[r'starts_at'] != null,
'Required key "RaidInstanceSchema[starts_at]" has a null value in JSON.');
assert(json.containsKey(r'ends_at'),
'Required key "RaidInstanceSchema[ends_at]" is missing from JSON.');
assert(json[r'ends_at'] != null,
'Required key "RaidInstanceSchema[ends_at]" has a null value in JSON.');
assert(json.containsKey(r'status'),
'Required key "RaidInstanceSchema[status]" is missing from JSON.');
assert(json[r'status'] != null,
'Required key "RaidInstanceSchema[status]" has a null value in JSON.');
assert(json.containsKey(r'total_hp'),
'Required key "RaidInstanceSchema[total_hp]" is missing from JSON.');
assert(json[r'total_hp'] != null,
'Required key "RaidInstanceSchema[total_hp]" has a null value in JSON.');
assert(json.containsKey(r'remaining_hp'),
'Required key "RaidInstanceSchema[remaining_hp]" is missing from JSON.');
assert(json[r'remaining_hp'] != null,
'Required key "RaidInstanceSchema[remaining_hp]" has a null value in JSON.');
return true;
}());
return RaidInstanceSchema(
startsAt: mapDateTime(json, r'starts_at', r'')!,
endsAt: mapDateTime(json, r'ends_at', r'')!,
status: RaidStatus.fromJson(json[r'status'])!,
totalHp: mapValueOfType<int>(json, r'total_hp')!,
remainingHp: mapValueOfType<int>(json, r'remaining_hp')!,
participantCount: mapValueOfType<int>(json, r'participant_count') ?? 0,
endedAt: mapDateTime(json, r'ended_at', r''),
result: RaidInstanceResult.fromJson(json[r'result']),
rewardsDistributedAt: mapDateTime(json, r'rewards_distributed_at', r''),
);
}
return null;
}