nuget 0.1.1 copy "nuget: ^0.1.1" to clipboard
nuget: ^0.1.1 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
  • 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();
}

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();
}

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();
}

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();
}

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();
}

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();
}

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();
}

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();
}

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();
}

Feature requests and bugs #

Please file feature requests and bugs at the issue tracker.

1
likes
160
pub points
53%
popularity

Publisher

verified publisherhalildurmus.dev

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

Repository (GitHub)
View/report issues

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