dart_fsnotify library

dartnotify — cross-platform filesystem notifications for Dart.

Inspired by fsnotify for Go.

Quickstart

import 'package:dartnotify/dartnotify.dart';

void main() async {
  final watcher = await Watcher.create();

  await watcher.add('/tmp/watch-me');

  watcher.events.listen((event) {
    print('[${event.op}] ${event.name}');
  });

  watcher.errors.listen((err) {
    print('Error: $err');
  });

  // Keep alive for 30 seconds, then shut down.
  await Future.delayed(const Duration(seconds: 30));
  await watcher.close();
}

Classes

FsEvent
Represents a single filesystem event emitted by a Watcher.
Op
Filesystem event operation flags.
Watcher
A cross-platform filesystem watcher.

Exceptions / Errors

WatcherError
Thrown when an error occurs inside the watcher.