PluginDetails.fromJson constructor

PluginDetails.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json, {
  4. ClientUriConverter? clientUriConverter,
})

Implementation

factory PluginDetails.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is Map) {
    String name;
    if (json.containsKey('name')) {
      name = jsonDecoder.decodeString('$jsonPath.name', json['name']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, "'name'", json);
    }
    List<String> lintRules;
    if (json.containsKey('lintRules')) {
      lintRules = jsonDecoder.decodeList(
        '$jsonPath.lintRules',
        json['lintRules'],
        jsonDecoder.decodeString,
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, "'lintRules'", json);
    }
    List<String> warningRules;
    if (json.containsKey('warningRules')) {
      warningRules = jsonDecoder.decodeList(
        '$jsonPath.warningRules',
        json['warningRules'],
        jsonDecoder.decodeString,
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, "'warningRules'", json);
    }
    List<AssistDescription> assists;
    if (json.containsKey('assists')) {
      assists = jsonDecoder.decodeList(
        '$jsonPath.assists',
        json['assists'],
        (String jsonPath, Object? json) => AssistDescription.fromJson(
          jsonDecoder,
          jsonPath,
          json,
          clientUriConverter: clientUriConverter,
        ),
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, "'assists'", json);
    }
    List<FixDescription> fixes;
    if (json.containsKey('fixes')) {
      fixes = jsonDecoder.decodeList(
        '$jsonPath.fixes',
        json['fixes'],
        (String jsonPath, Object? json) => FixDescription.fromJson(
          jsonDecoder,
          jsonPath,
          json,
          clientUriConverter: clientUriConverter,
        ),
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, "'fixes'", json);
    }
    return PluginDetails(name, lintRules, warningRules, assists, fixes);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'PluginDetails'", json);
  }
}