watch function Null safety

Stream<WatchEvent> watch(
  1. String directory,
  2. {required Glob files}
)

Watch directory for changes in whole subtree except public directory.

Implementation

Stream<WatchEvent> watch(
  String directory, {
  required Glob files,
}) {
  return DirectoryWatcher(
    directory,
    pollingDelay: const Duration(milliseconds: 250),
  )
      .events
      .where((e) => files.matches(e.path))
      .map((event) => WatchEvent(event.type, Uri.file(event.path).toString()));
}