isPubPackageRoot function

Future<bool> isPubPackageRoot(
  1. String dirPath, {
  2. bool verbose = false,
  3. FilterDartProjectOptions? filterDartProjectOptions,
})

return true if root package Check whether the package contains a supported version

Implementation

/// Check whether the package contains a supported version
Future<bool> isPubPackageRoot(
  String dirPath, {
  bool verbose = false,
  FilterDartProjectOptions? filterDartProjectOptions,
}) async {
  var pubspecYamlPath = join(dirPath, _pubspecYaml);
  // ignore: avoid_slow_async_io
  if (await io.FileSystemEntity.isFile(pubspecYamlPath)) {
    try {
      var map = await pathGetPubspecYamlMap(dirPath);
      var boundaries = pubspecYamlGetSdkBoundaries(map);
      if (boundaries == null) {
        return false;
      }
      if (filterDartProjectOptions?.hasConstraintsOverride() ?? false) {
        return filterDartProjectOptions!.matchesBoundaries(boundaries);
      }
      return boundaries.matches(dartVersion);
    } catch (_) {}
  }
  return false;
}