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) {
    String pluginName;
    if (json.containsKey('pluginName')) {
      pluginName = jsonDecoder.decodeString(
        '$jsonPath.pluginName',
        json['pluginName'],
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, "'pluginName'", json);
    }
    String message;
    if (json.containsKey('message')) {
      message = jsonDecoder.decodeString(
        '$jsonPath.message',
        json['message'],
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, "'message'", json);
    }
    int timestamp;
    if (json.containsKey('timestamp')) {
      timestamp = jsonDecoder.decodeInt(
        '$jsonPath.timestamp',
        json['timestamp'],
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, "'timestamp'", json);
    }
    return PluginPrint(pluginName, message, timestamp);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'PluginPrint'", json);
  }
}