watchFlutterLib function

void watchFlutterLib(
  1. String flutterProject, {
  2. required void onEdit(
    1. String path
    ),
})

watch FLUTTER/lib/..

Implementation

void watchFlutterLib(
  String flutterProject, {
  required void Function(String path) onEdit,
}) {
  const watcherDelay = Duration(seconds: 1);
  final watcher = DirectoryWatcher(
    '$flutterProject${Platform.pathSeparator}lib',
    pollingDelay: watcherDelay,
  );
  watcher.events.listen((change) async {
    if (change.type == ChangeType.MODIFY) {
      onEdit(change.path);
    }
  });
}