fromJson static method
Returns a new RaidSchema instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static RaidSchema? 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'code'),
'Required key "RaidSchema[code]" is missing from JSON.');
assert(json[r'code'] != null,
'Required key "RaidSchema[code]" has a null value in JSON.');
assert(json.containsKey(r'name'),
'Required key "RaidSchema[name]" is missing from JSON.');
assert(json[r'name'] != null,
'Required key "RaidSchema[name]" has a null value in JSON.');
assert(json.containsKey(r'monster'),
'Required key "RaidSchema[monster]" is missing from JSON.');
assert(json[r'monster'] != null,
'Required key "RaidSchema[monster]" has a null value in JSON.');
assert(json.containsKey(r'schedule'),
'Required key "RaidSchema[schedule]" is missing from JSON.');
assert(json[r'schedule'] != null,
'Required key "RaidSchema[schedule]" has a null value in JSON.');
assert(json.containsKey(r'status'),
'Required key "RaidSchema[status]" is missing from JSON.');
assert(json[r'status'] != null,
'Required key "RaidSchema[status]" has a null value in JSON.');
assert(json.containsKey(r'next_start_at'),
'Required key "RaidSchema[next_start_at]" is missing from JSON.');
assert(json[r'next_start_at'] != null,
'Required key "RaidSchema[next_start_at]" has a null value in JSON.');
return true;
}());
return RaidSchema(
code: mapValueOfType<String>(json, r'code')!,
name: mapValueOfType<String>(json, r'name')!,
description: mapValueOfType<String>(json, r'description'),
monster: mapValueOfType<String>(json, r'monster')!,
schedule: RaidScheduleSchema.fromJson(json[r'schedule'])!,
rewards: RaidRewardsSchema.fromJson(json[r'rewards']),
status: RaidStatus.fromJson(json[r'status'])!,
nextStartAt: mapDateTime(json, r'next_start_at', r'')!,
participantCount: mapValueOfType<int>(json, r'participant_count') ?? 0,
activeInstance: RaidInstanceSchema.fromJson(json[r'active_instance']),
latestInstance: RaidInstanceSchema.fromJson(json[r'latest_instance']),
);
}
return null;
}