AnalysisHandleWatchEventsParams.fromJson constructor

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

Implementation

factory AnalysisHandleWatchEventsParams.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(
      jsonPath,
      "'analysis.handleWatchEvents params'",
      json,
    );
  }
  List<WatchEvent> events;
  if (json case {'events': var encodedEvents}) {
    events = jsonDecoder.decodeList(
      '$jsonPath.events',
      encodedEvents,
      (String jsonPath, Object? json) => WatchEvent.fromJson(
        jsonDecoder,
        jsonPath,
        json,
        clientUriConverter: clientUriConverter,
      ),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'events'", json);
  }
  return AnalysisHandleWatchEventsParams(events);
}