startWatch method

Future<void> startWatch(
  1. String className
)

Watch all paths

Implementation

Future<void> startWatch(String className) async {
  if (!isWatch) {
    return;
  }
  if (_watching) {
    return;
  }
  _watching = true;
  for (final Directory dir in dirList) {
    final StreamSubscription<FileSystemEvent>? sub = _watch(dir);
    if (sub != null) {
      sub.onDone(sub.cancel);
    }
    watchMap[dir] = sub;
  }
  final File pubspec = File('$projectRootPath${separator}pubspec.yaml');
  // ignore: cancel_subscriptions
  final StreamSubscription<FileSystemEvent>? sub = _watch(pubspec);
  if (sub != null) {
    watchMap[pubspec] = sub;
  }
  print('Watching all resources file.');
}