PluginVersionCheckParams.fromJson constructor

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

Implementation

factory PluginVersionCheckParams.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(
      jsonPath,
      "'plugin.versionCheck params'",
      json,
    );
  }
  String byteStorePath;
  if (json case {'byteStorePath': var encodedByteStorePath}) {
    byteStorePath =
        clientUriConverter?.fromClientFilePath(
          jsonDecoder.decodeString(
            '$jsonPath.byteStorePath',
            encodedByteStorePath,
          ),
        ) ??
        jsonDecoder.decodeString(
          '$jsonPath.byteStorePath',
          encodedByteStorePath,
        );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'byteStorePath'", json);
  }
  String sdkPath;
  if (json case {'sdkPath': var encodedSdkPath}) {
    sdkPath =
        clientUriConverter?.fromClientFilePath(
          jsonDecoder.decodeString('$jsonPath.sdkPath', encodedSdkPath),
        ) ??
        jsonDecoder.decodeString('$jsonPath.sdkPath', encodedSdkPath);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'sdkPath'", json);
  }
  String version;
  if (json case {'version': var encodedVersion}) {
    version = jsonDecoder.decodeString('$jsonPath.version', encodedVersion);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'version'", json);
  }
  return PluginVersionCheckParams(byteStorePath, sdkPath, version);
}