fromJson static method

FindingView? fromJson(
  1. dynamic value
)

Returns a new FindingView instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static FindingView? 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 "FindingView[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "FindingView[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return FindingView(
      createdAt: mapValueOfType<int>(json, r'createdAt'),
      fingerprint: mapValueOfType<String>(json, r'fingerprint'),
      id: mapValueOfType<String>(json, r'id'),
      line: mapValueOfType<int>(json, r'line'),
      path: mapValueOfType<String>(json, r'path'),
      preview: mapValueOfType<String>(json, r'preview'),
      ruleId: mapValueOfType<String>(json, r'ruleId'),
      ruleName: mapValueOfType<String>(json, r'ruleName'),
      scanId: mapValueOfType<String>(json, r'scanId'),
      severity: mapValueOfType<String>(json, r'severity'),
    );
  }
  return null;
}