in lib/src/directory_watcher/windows.dart [386:403]
void _startWatch() {
// Note: "watcher closed" exceptions do not get sent over the stream
// returned by watch, and must be caught via a zone handler.
runZonedGuarded(() {
var innerStream = Directory(path).watch(recursive: true);
_watchSubscription = innerStream.listen(_onEvent,
onError: _eventsController.addError, onDone: _onDone);
}, (error, stackTrace) {
if (error is FileSystemException &&
error.message.startsWith('Directory watcher closed unexpectedly')) {
_watchSubscription?.cancel();
_eventsController.addError(error, stackTrace);
_startWatch();
} else {
throw error;
}
});
}