computeDevWatchPaths function
The watched surface for a dev session (absolute paths): lib/, the
target file, android/, assets/, oka.yaml, pubspec.yaml.
Missing paths are skipped (a pure-Dart project may have no android/).
Implementation
List<String> computeDevWatchPaths({
required String projectPath,
String? targetFile,
}) {
final candidates = <String>[
p.join(projectPath, 'lib'),
p.join(projectPath, 'android'),
p.join(projectPath, 'assets'),
p.join(projectPath, 'oka.yaml'),
p.join(projectPath, 'pubspec.yaml'),
];
final resolvedTarget = (targetFile == null || targetFile.isEmpty)
? null
: (p.isAbsolute(targetFile)
? targetFile
: p.join(projectPath, targetFile));
if (resolvedTarget != null) {
// Skip the target when a watched root already covers it (e.g.
// lib/main.dart under the lib/ watcher).
final covered = candidates.any(
(c) => _isDir(c) && p.isWithin(c, resolvedTarget),
);
if (!covered) candidates.add(resolvedTarget);
}
return [
for (final c in candidates)
if (_exists(c)) c,
];
}