Watcher class
A cross-platform filesystem watcher.
Watcher wraps Dart's dart:io watch streams and exposes a unified stream of
FsEvent objects, matching the ergonomics of Go's fsnotify package.
Use Watcher.create to instantiate and start watching:
final watcher = await Watcher.create();
await watcher.add('/tmp/mydir');
watcher.events.listen((event) {
print(event);
});
watcher.errors.listen((err) {
print('Watch error: $err');
});
// Later...
await watcher.close();
Properties
-
errors
→ Stream<
WatcherError> -
A broadcast stream of WatcherErrors from all watched paths.
no setter
-
events
→ Stream<
FsEvent> -
A broadcast stream of FsEvents emitted for all watched paths.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
watchList
→ Set<
String> -
Returns the set of paths currently being watched.
no setter
Methods
-
add(
String path, {bool recursive = false}) → Future< void> -
Adds
pathto the watch list. -
close(
) → Future< void> - Closes the watcher and releases all resources.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
String path) → Future< void> -
Removes
pathfrom the watch list and stops watching it. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited