watch method
Start watching the FileSystemEntity for changes.
The implementation uses platform-dependent event-based APIs for receiving file-system notifications, thus behavior depends on the platform.
-
Windows
: UsesReadDirectoryChangesW
. The implementation only supports watching directories. Recursive watching is supported. -
Linux
: Usesinotify
. The implementation supports watching both files and directories. Recursive watching is not supported. Note: When watching files directly, delete events might not happen as expected. -
OS X
: Uses the File System Events API. The implementation supports watching both files and directories. Recursive watching is supported. This API has several limitations:
The system will start listening for events once the returned Stream is being listened to, not when the call to watch is issued.
The returned value is an endless broadcast Stream, that only stops when one of the following happens:
- The Stream is canceled, e.g. by calling
cancel
on the StreamSubscription. - The FileSystemEntity being watched is deleted.
- System Watcher exits unexpectedly. e.g. On
Windows
this happens when buffer that receive events fromReadDirectoryChangesW
overflows.
Use events
to specify what events to listen for. The constants in
FileSystemEvent can be or'ed together to mix events. Default is
FileSystemEvent.all.
A move event may be reported as separate delete and create events.
Implementation
@override
Stream<FileSystemEvent> watch(
{int events = FileSystemEvent.all, bool recursive = false}) {
throw UnimplementedError();
}