PluginPrint.fromJson constructor

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

Implementation

factory PluginPrint.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(jsonPath, "'PluginPrint'", json);
  }
  String pluginName;
  if (json case {'pluginName': var encodedPluginName}) {
    pluginName = jsonDecoder.decodeString(
      '$jsonPath.pluginName',
      encodedPluginName,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'pluginName'", json);
  }
  String message;
  if (json case {'message': var encodedMessage}) {
    message = jsonDecoder.decodeString('$jsonPath.message', encodedMessage);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'message'", json);
  }
  int timestamp;
  if (json case {'timestamp': var encodedTimestamp}) {
    timestamp = jsonDecoder.decodeInt(
      '$jsonPath.timestamp',
      encodedTimestamp,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'timestamp'", json);
  }
  return PluginPrint(pluginName, message, timestamp);
}