fetchPackageScore method

Future<PackageScore> fetchPackageScore(
  1. String packageName
)

The score facts recorded for a package's latest version (SPEC ยง3.1.3): its tags, like count and 30-day download count.

Implementation

Future<PackageScore> fetchPackageScore(String packageName) async {
  final uri = _baseUri.resolve('/api/packages/$packageName/score');
  final body = await _getJson(uri);
  return PackageScore(
    tags: (body['tags'] as List? ?? const []).cast<String>(),
    likeCount: body['likeCount'] as int? ?? 0,
    downloadCount30Days: body['downloadCount30Days'] as int? ?? 0,
  );
}