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