startWatch method
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;
}
final File configFile = File('$projectRootPath${separator}fgen.yaml');
if (configFile.existsSync()) {
// ignore: cancel_subscriptions
final StreamSubscription<FileSystemEvent>? configFileSub =
_watch(configFile);
if (sub != null) {
watchMap[configFile] = configFileSub;
}
}
print('Watching all resources file.');
}