Watch for file changes in Dart

2019-05-21 09:41发布

问题:

Is it possible to watch for file changes (deletion, creation, edit) in Dart, like in NodeJS?

I do not seem to be able to find an answer to this, is it possible that it will be implemented in the future?

回答1:

You want to take a look at FileSystemEntity.watch() method. However due to platform differences some platforms provide better support than others. In particular, on Windows you can only watch a Directory, and not just an individual file. On Linux you can watch Files or Directories but not recursively watch Directories. And MacOS supports all of the above.

There is also a watcher package on Pub, however at this time I cannot find any reference to the API documentation associated with this package.



标签: dart