WatchEvent.fromJson constructor
WatchEvent.fromJson(})
Implementation
factory WatchEvent.fromJson(
JsonDecoder jsonDecoder,
String jsonPath,
Object? json, {
ClientUriConverter? clientUriConverter,
}) {
json ??= {};
if (json is! Map) {
throw jsonDecoder.mismatch(jsonPath, "'WatchEvent'", json);
}
WatchEventType type;
if (json case {'type': var encodedType}) {
type = WatchEventType.fromJson(
jsonDecoder,
'$jsonPath.type',
encodedType,
clientUriConverter: clientUriConverter,
);
} else {
throw jsonDecoder.mismatch(jsonPath, "'type'", json);
}
String path;
if (json case {'path': var encodedPath}) {
path =
clientUriConverter?.fromClientFilePath(
jsonDecoder.decodeString('$jsonPath.path', encodedPath),
) ??
jsonDecoder.decodeString('$jsonPath.path', encodedPath);
} else {
throw jsonDecoder.mismatch(jsonPath, "'path'", json);
}
return WatchEvent(type, path);
}