projectPackageConfigUri property

FutureOr<Uri> get projectPackageConfigUri

The resolved project .dart_tool/package_config.json Uri.

Implementation

FutureOr<Uri> get projectPackageConfigUri {
  var uriPackageConfigJson = projectSubUri('.dart_tool/package_config.json');
  var uriPackages = projectSubUri('.packages');

  var filePackageConfigJson =
      uriPackageConfigJson.resolveMapped((uri) => File.fromUri(uri));
  var filePackages = uriPackages.resolveMapped((uri) => File.fromUri(uri));

  return filePackageConfigJson.resolveBoth(filePackages,
      (fileJson, filePack) {
    if (fileJson.existsSync()) {
      return uriPackageConfigJson;
    } else if (filePack.existsSync()) {
      return uriPackages;
    } else {
      throw StateError(
          "Can't resolve project packageConfig: $fileJson ; $filePack");
    }
  });
}