packageExists method
Determines whether the package with the packageId
exists.
If version
is specified, it also checks whether the package has the
specified version
.
Throws a NuGetServerException if the server returns a non-200 status code.
Implementation
Future<bool> packageExists(String packageId, {String? version}) async {
if (!_isInitialized) await _initialize();
try {
final resource = _getResource<PackageContentResource>();
final versions = await resource.getPackageVersions(packageId);
if (version != null) return versions.contains(version);
return versions.isNotEmpty;
} on PackageNotFoundException {
return false;
}
}