tryFindProjectDirectory function
Finds the project directory associated with an analysis context root, or null if it is not found
This is a folder that contains both a pubspec.yaml
and a .dart_tool/package_config.json
file.
It is either alongside the analysis_options.yaml file, or in a parent directory.
Implementation
Directory? tryFindProjectDirectory(
Directory directory, {
Directory? original,
}) {
try {
return findProjectDirectory(
directory,
original: original,
);
} catch (_) {
return null;
}
}