PluginVersionCheckResult.fromJson constructor

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

Implementation

factory PluginVersionCheckResult.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(
      jsonPath,
      "'plugin.versionCheck result'",
      json,
    );
  }
  bool isCompatible;
  if (json case {'isCompatible': var encodedIsCompatible}) {
    isCompatible = jsonDecoder.decodeBool(
      '$jsonPath.isCompatible',
      encodedIsCompatible,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'isCompatible'", json);
  }
  String name;
  if (json case {'name': var encodedName}) {
    name = jsonDecoder.decodeString('$jsonPath.name', encodedName);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'name'", json);
  }
  String version;
  if (json case {'version': var encodedVersion}) {
    version = jsonDecoder.decodeString('$jsonPath.version', encodedVersion);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'version'", json);
  }
  String? contactInfo;
  if (json case {'contactInfo': var encodedContactInfo}) {
    contactInfo = jsonDecoder.decodeString(
      '$jsonPath.contactInfo',
      encodedContactInfo,
    );
  }
  List<String> interestingFiles;
  if (json case {'interestingFiles': var encodedInterestingFiles}) {
    interestingFiles = jsonDecoder.decodeList(
      '$jsonPath.interestingFiles',
      encodedInterestingFiles,
      jsonDecoder.decodeString,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'interestingFiles'", json);
  }
  return PluginVersionCheckResult(
    isCompatible,
    name,
    version,
    interestingFiles,
    contactInfo: contactInfo,
  );
}