in lib/src/file_watcher/polling.dart [52:87]
Future _poll() async {
// We don't mark the file as removed if this is the first poll (indicated by
// [_lastModified] being null). Instead, below we forward the dart:io error
// that comes from trying to read the mtime below.
var pathExists = await File(path).exists();
if (_eventsController.isClosed) return;
if (_lastModified != null && !pathExists) {
_eventsController.add(WatchEvent(ChangeType.REMOVE, path));
unawaited(close());
return;
}
DateTime? modified;
try {
modified = await modificationTime(path);
} on FileSystemException catch (error, stackTrace) {
if (!_eventsController.isClosed) {
_eventsController.addError(error, stackTrace);
await close();
}
}
if (_eventsController.isClosed) return;
if (_lastModified == modified) return;
if (_lastModified == null) {
// If this is the first poll, don't emit an event, just set the last mtime
// and complete the completer.
_lastModified = modified;
_readyCompleter.complete();
} else {
_lastModified = modified;
_eventsController.add(WatchEvent(ChangeType.MODIFY, path));
}
}