PluginConfiguration.fromJson constructor

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

Implementation

factory PluginConfiguration.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(jsonPath, "'PluginConfiguration'", json);
  }
  bool enabled;
  if (json case {'enabled': var encodedEnabled}) {
    enabled = jsonDecoder.decodeBool('$jsonPath.enabled', encodedEnabled);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'enabled'", json);
  }
  Map<String, String> diagnosticSeverities;
  if (json case {'diagnosticSeverities': var encodedDiagnosticSeverities}) {
    diagnosticSeverities = jsonDecoder.decodeMap(
      '$jsonPath.diagnosticSeverities',
      encodedDiagnosticSeverities,
      valueDecoder: jsonDecoder.decodeString,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'diagnosticSeverities'", json);
  }
  return PluginConfiguration(enabled, diagnosticSeverities);
}