fromJson static method
Flag2?
fromJson(
- dynamic value
)
Returns a new Flag2 instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static Flag2? 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 "Flag2[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "Flag2[$key]" has a null value in JSON.');
});
return true;
}());
return Flag2(
createdAt: mapDateTime(json, r'created_at', r'')!,
custom: mapCastOfType<String, Object>(json, r'custom') ?? const {},
entityCreatorId: mapValueOfType<String>(json, r'entity_creator_id'),
entityId: mapValueOfType<String>(json, r'entity_id')!,
entityType: mapValueOfType<String>(json, r'entity_type')!,
labels: json[r'labels'] is Iterable
? (json[r'labels'] as Iterable).cast<String>().toList(growable: false)
: const [],
moderationPayload: ModerationPayload.fromJson(json[r'moderation_payload']),
moderationPayloadHash: mapValueOfType<String>(json, r'moderation_payload_hash'),
reason: mapValueOfType<String>(json, r'reason'),
// MANUAL_EDIT: mapListOfMapFromJson() instead of mapFromJson()
result: mapListOfMapFromJson(json[r'result']),
reviewQueueItemId: mapValueOfType<String>(json, r'review_queue_item_id'),
type: mapValueOfType<String>(json, r'type'),
updatedAt: mapDateTime(json, r'updated_at', r'')!,
user: UserObject.fromJson(json[r'user']),
);
}
return null;
}