PluginErrorParams.fromJson constructor

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

Implementation

factory PluginErrorParams.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(jsonPath, "'plugin.error params'", json);
  }
  bool isFatal;
  if (json case {'isFatal': var encodedIsFatal}) {
    isFatal = jsonDecoder.decodeBool('$jsonPath.isFatal', encodedIsFatal);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'isFatal'", json);
  }
  String message;
  if (json case {'message': var encodedMessage}) {
    message = jsonDecoder.decodeString('$jsonPath.message', encodedMessage);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'message'", json);
  }
  String stackTrace;
  if (json case {'stackTrace': var encodedStackTrace}) {
    stackTrace = jsonDecoder.decodeString(
      '$jsonPath.stackTrace',
      encodedStackTrace,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'stackTrace'", json);
  }
  return PluginErrorParams(isFatal, message, stackTrace);
}