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) {
    String byteStorePath;
    if (json.containsKey('byteStorePath')) {
      byteStorePath = clientUriConverter?.fromClientFilePath(
              jsonDecoder.decodeString(
                  '$jsonPath.byteStorePath', json['byteStorePath'])) ??
          jsonDecoder.decodeString(
              '$jsonPath.byteStorePath', json['byteStorePath']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'byteStorePath');
    }
    String sdkPath;
    if (json.containsKey('sdkPath')) {
      sdkPath = clientUriConverter?.fromClientFilePath(jsonDecoder
              .decodeString('$jsonPath.sdkPath', json['sdkPath'])) ??
          jsonDecoder.decodeString('$jsonPath.sdkPath', json['sdkPath']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'sdkPath');
    }
    String version;
    if (json.containsKey('version')) {
      version =
          jsonDecoder.decodeString('$jsonPath.version', json['version']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'version');
    }
    return PluginVersionCheckParams(byteStorePath, sdkPath, version);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'plugin.versionCheck params', json);
  }
}