nuget 0.2.0 copy "nuget: ^0.2.0" to clipboard
nuget: ^0.2.0 copied to clipboard

A Dart package that allows interaction with the NuGet Server API.

ci Package: nuget Publisher: halildurmus.dev Language: Dart License: BSD-3-Clause codecov

A Dart package that allows interaction with the NuGet Server API. This package provides easy access to the NuGet Server API, allowing you to perform various operations such as querying package information, downloading package content, fetching package metadata, and more.

Features #

  • Autocomplete package IDs
  • Download package content (.nupkg)
  • Download package manifest (.nuspec)
  • Get all package metadata (all versions)
  • Get latest package version
  • Get package metadata (specific version)
  • Get package versions
  • Check if a package exists
  • Get report abuse URL for a package
  • Search packages

Usage #

Autocomplete package IDs #

import 'package:nuget/nuget.dart';

void main() async {
  // Create an instance of NuGetClient.
  final client = NuGetClient();

  const query = 'win32';
  final response = await client.autocompletePackageIds(query);
  print('The `$query` query returned ${response.totalHits} hits. '
      'Here are the first 20 results:');
  for (final packageId in response.data) {
    print(' - $packageId');
  }

  // Close the client when it's no longer needed.
  client.close();
}
copied to clipboard

Download package content (.nupkg) #

import 'package:nuget/nuget.dart';

void main() async {
  final client = NuGetClient();

  const packageId = 'Newtonsoft.Json';
  const version = '13.0.3';
  final content =
      await client.downloadPackageContent(packageId, version: version);
  print('`$packageId` ($version) package size: ${content.length} bytes');

  client.close();
}
copied to clipboard

Download package manifest (.nuspec) #

import 'package:nuget/nuget.dart';

void main() async {
  final client = NuGetClient();

  const packageId = 'Newtonsoft.Json';
  const version = '13.0.3';
  final manifest =
      await client.downloadPackageManifest(packageId, version: version);
  print('`$packageId` ($version) manifest size: ${manifest.length} bytes');

  client.close();
}
copied to clipboard

Get all package metadata (all versions) #

import 'package:nuget/nuget.dart';

void main() async {
  final client = NuGetClient();

  const packageId = 'Newtonsoft.Json';
  final allMetadata = await client.getAllPackageMetadata(packageId);
  print('`$packageId` metadata of first three versions:');
  for (final metadata in allMetadata.take(3)) {
    print(' - Version: ${metadata.version}');
    print(' - Description: ${metadata.description}');
    print(' - Author(s): ${metadata.authors}');
    print('');
  }

  client.close();
}
copied to clipboard

Get latest package version #

import 'package:nuget/nuget.dart';

void main() async {
  final client = NuGetClient();

  const packageId = 'Newtonsoft.Json';
  final latestVersion = await client.getLatestPackageVersion(packageId);
  print('`$packageId` latest version: $latestVersion');

  client.close();
}
copied to clipboard

Get package metadata (specific version) #

import 'package:nuget/nuget.dart';

void main() async {
  final client = NuGetClient();

  const packageId = 'Newtonsoft.Json';
  const version = '13.0.3';
  final metadata = await client.getPackageMetadata(packageId, version: version);
  print('`$packageId` ($version) metadata:');
  print(' - Version: ${metadata.version}');
  print(' - Description: ${metadata.description}');
  print(' - Author(s): ${metadata.authors}');

  client.close();
}
copied to clipboard

Get package versions #

import 'package:nuget/nuget.dart';

void main() async {
  final client = NuGetClient();

  const packageId = 'Newtonsoft.Json';
  final versions = await client.getPackageVersions(packageId);
  print('`$packageId` has ${versions.length} versions:');
  for (final version in versions) {
    print(' - $version');
  }

  client.close();
}
copied to clipboard

Check if a package exists #

import 'package:nuget/nuget.dart';

void main() async {
  final client = NuGetClient();

  const packageId = 'Newtonsoft.Json';
  final exists = await client.packageExists(packageId);
  print('`$packageId` exists: $exists');

  client.close();
}
copied to clipboard

Get report abuse URL for a package #

import 'package:nuget/nuget.dart';

void main() async {
  final client = NuGetClient();

  const packageId = 'Newtonsoft.Json';
  const version = '13.0.3';
  final reportAbuseUrl = await client.getReportAbuseUrl(packageId, version);
  print('Report abuse URL for `$packageId` ($version): $reportAbuseUrl');

  client.close();
}
copied to clipboard

Search packages #

import 'package:nuget/nuget.dart';

void main() async {
  final client = NuGetClient();

  const query = 'win32';
  final searchResponse = await client.searchPackages(query);
  print('The `$query` query returned ${searchResponse.totalHits} hits. Here '
      'are the first 20 results:');
  for (final package in searchResponse.data) {
    print(' - ${package.packageId} (${package.version})');
  }

  client.close();
}
copied to clipboard

Feature requests and bugs #

Please file feature requests and bugs at the issue tracker.

1
likes
160
points
214
downloads

Publisher

verified publisherhalildurmus.dev

Weekly Downloads

2024.08.09 - 2025.02.21

A Dart package that allows interaction with the NuGet Server API.

Repository (GitHub)
View/report issues
Contributing

Topics

#nuget #nuget-server-api #nuget-api #api

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

http, version

More

Packages that depend on nuget