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