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) {
    throw jsonDecoder.mismatch(jsonPath, "'PluginDetails'", json);
  }
  String name;
  if (json case {'name': var encodedName}) {
    name = jsonDecoder.decodeString('$jsonPath.name', encodedName);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'name'", json);
  }
  List<String> lintRules;
  if (json case {'lintRules': var encodedLintRules}) {
    lintRules = jsonDecoder.decodeList(
      '$jsonPath.lintRules',
      encodedLintRules,
      jsonDecoder.decodeString,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'lintRules'", json);
  }
  List<String> warningRules;
  if (json case {'warningRules': var encodedWarningRules}) {
    warningRules = jsonDecoder.decodeList(
      '$jsonPath.warningRules',
      encodedWarningRules,
      jsonDecoder.decodeString,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'warningRules'", json);
  }
  List<AssistDescription> assists;
  if (json case {'assists': var encodedAssists}) {
    assists = jsonDecoder.decodeList(
      '$jsonPath.assists',
      encodedAssists,
      (String jsonPath, Object? json) => AssistDescription.fromJson(
        jsonDecoder,
        jsonPath,
        json,
        clientUriConverter: clientUriConverter,
      ),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'assists'", json);
  }
  List<FixDescription> fixes;
  if (json case {'fixes': var encodedFixes}) {
    fixes = jsonDecoder.decodeList(
      '$jsonPath.fixes',
      encodedFixes,
      (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);
}