leoafarias / pub_api_client Goto Github PK
View Code? Open in Web Editor NEWThe most complete & unofficial API Client for Dart Pub.dev
Home Page: https://pub.dev/packages/pub_api_client
License: MIT License
The most complete & unofficial API Client for Dart Pub.dev
Home Page: https://pub.dev/packages/pub_api_client
License: MIT License
If a package was recently updated, some of the information in PackageScore can be null. For example: grantedPubPoints and popularityScore. These should be handled by the client.
In one of my app I was trying to bump the version of freezed_annotation
to the current version 2.1.0
and freezed
version 2.1.0+1
but when I run flutter pub get
the terminal shows me:
Running "flutter pub get" in pubhub...
Because pub_api_client 2.2.1 depends on freezed_annotation ^1.1.0 and no versions of pub_api_client match >2.2.1 <3.0.0, pub_api_client ^2.2.1 requires freezed_annotation ^1.1.0.
So, because pubhub depends on both freezed_annotation ^2.1.0 and pub_api_client ^2.2.1, version solving failed.
pub get failed (1; So, because pubhub depends on both freezed_annotation ^2.1.0 and pub_api_client ^2.2.1, version solving failed.)
exit code 1
So I have to leave freezed*
versions like that:
dependencies:
flutter:
sdk: flutter
...
freezed_annotation: ^1.1.0
dev_dependencies:
...
freezed: ^1.1.1
Is it possible to upgrade freezed*
versions to the latest 2.x.y
?
Thanks,
Alberto
If we make the following GET request: https://pub.dev/api/packages/go_router/versions/13.2.0
which is reflected in the Package as packageVersionInfo
we receive in the pubspec
section repository
and issue_tracker.
It would be great if we could add them as nullable strings to this package
Looking at the source, trying to find something that would just list all the available package names, I found the below function:
/// Returns a List<String>
of all packages listed on pub.dev
Future<List> packageNameCompletion() async
Unfortunately, that does not appear to work, but causes an unhandled exception:
Unhandled exception:
#0 responseValidOrThrow (package:pub_api_client/src/helpers/exceptions.dart:55:7)
#1 PubClient._fetch (package:pub_api_client/src/pub_api_client_base.dart:54:5)
#2 PubClient.packageNameCompletion (package:pub_api_client/src/pub_api_client_base.dart:126:18)
I have a bit of code that calls await packageInfo(packageName)
in a loop. The info is properly returned for each package queried.
Yet when I end the loop to exit the program, I don't get a prompt or in the android studio debugger the stop button is enabled as if the program were still running.
There's some sort of timeout that once reached, the program does exit.
I have tried using a single Client instance and one per query, with the same results.
If I were to guess, I'd say the HTTP socket is keep-alive and the code won't exit until that socket is closed.
If this is the case, my suggestion would be some sort of destroy(), close(), or cleanup() on the client instance to force close the socket.
I don't see one here:
https://pub.dev/documentation/pub_api_client/latest/pub_api_client/pub_api_client-library.html or
https://pub.dev/documentation/pub_api_client/latest/pub_api_client/PubClient-class.html
It's probably a good idea to implement such a function, even if it simply returns (for now).
It would be useful to be able to access a packages license name (the way pub.dev webpage for a package shows it), eg. "MIT".
Hi everyone, for one of my side projects I'm using this package to create a desktop app to browse pub.dev using the same concept of the AppStore, Windows Store, or other stores on Linux distros.
In my case I need to create a section with the list of packages of the Flutter Favorite program and those associated with Google that can be retrieved respectively with this two APIs:
fetchGooglePackages
fetchFlutterFavorites
Unfortunately, these two functions only return the List <String>
with the package names while in my case I would need the complete information about the package represented by the PubPackage
object. Right now I solved this issue by calling the fetchFlutterFavorites
and after that in another widget call the packageInfo
API to get all the info, something like that using Riverpod:
final allFlutterFavoritesProvider = FutureProvider.autoDispose<List<String>>((ref) async {
return await PubClient().fetchFlutterFavorites();
});
final singlePackageProvider = FutureProvider.autoDispose.family<PubPackage, String>((ref, packageName) async {
return await PubClient().packageInfo(packageName);
});
[...]
Widget build(BuildContext context, WidgetRef ref) {
AsyncValue<List<String>> allFlutterFavoritesList = ref.watch(allFlutterFavoritesProvider);
return Column(
children: [
...
allFlutterFavoritesList.when(
loading: ...
error: ...
data: (list) {
return GridView.builder(
shrinkWrap: true,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: kDefaultPagePadding,
mainAxisSpacing: kDefaultPagePadding),
itemCount: list.length,
itemBuilder: (_, int index) {
return PackageGridBox(
packageName: list.elementAt(index),
);
},
);
},
),
],
);
}
[...]
class PackageGridBox extends ConsumerWidget {
const PackageGridBox({Key? key, required this.packageName}) : super(key: key);
final String packageName;
@override
Widget build(BuildContext context, WidgetRef ref) {
AsyncValue<PubPackage> singlePackage = ref.watch(singlePackageProvider(packageName));
return singlePackage.when(
loading: ...
error: ...
data: (package) {
return Container(
decoration: kDefaultBoxDecoration(context),
child: Text(package.toString()),
);
},
);
}
}
Do you think it might be useful to add an API that allows you to immediately have all the information about the packages and not just the package name? Something like that:
/// Retrieves all the flutter favorites PubPackage
Future<List<PubPackage>> fetchFlutterFavoritesPubPackage() async {
final searchResults = await search('is:flutter-favorite');
final results = await recursivePaging(this, searchResults);
return await Future.wait(
results.map((r) => packageInfo(r.package)).toList());
}
I know that for all the packages you must wait for all the packageInfo
calls but it might be useful to someone.
Best regards,
Alberto
Hey,
So I have been trying out the package lately. I know I can get whether or not the package has documentation, but can I get the actual documentation as markdown or just string?
Thank you.
I'm curious how much of a lift you feel it would be (or whether it's even possible) to expand this package to be able to interact with a third party hosting service such as Cloudsmith.
They must have a similar API set up at least for fetching package info and the latest version
etc.
My guess is it's probably a better idea to create a separate client, but it would be really cool if we had something like a packages_info
that supported querying for pub.dev packages as well as hosted packages.
My Use Case:
Any thoughts would be appreciated!
This package is surfacing this runtime exception, but I'm not sure it's this package's fault since there are no references to identityHashCode
in this code base. I'm creating an issue here to see if @leoafarias has any insight to what is going on.
Uncaught (in promise) CompileError: WebAssembly.compileStreaming(): Compiling function #1263:"identityHashCode" failed: type error in return[0] (expected i64, got (ref null 103)) @+1479968
Hey,
First and foremost, thank you for this awesome package.
So I have a very simple application where users can like pub packages. However as mentioned in the documentation, I will need to authenticate the user. Could you perhaps elaborate on how to authenticate?
Thank you.
Thanks for your package. This is awesome.
By the way, I'd like to use the likes API, but I can not find the user token on my local machine.
Where can I find the token?
Would it be possible to expose the model classes from src
too ? (like SearchResults
)
Now we're not able to have type annotations for them. :'(
Thanks for the package!
Experimented with some client mocking and mocked that a 404
request was returned with and empty response body = ""
.
Then I wanted to log the error message and called the toString()
method on the exception.
Unfortunately the jsonDecode method seems to assume valid formatted json and throws an exception if the body is empty.
The same exception can be reproduced with the following example:
void main() {
jsonDecode("");
}
Since we are already in exception land this additional exception is likely to jump the try/catch
boundary we are currently operating in.
For example:
void main(String packageName) {
try {
var client = PubClient();
client.packageVersions(packageName);
} catch (e) {
// Json decode exception is thrown here
print(e);
}
}
Don't assume valid json formatting if the request has failed. Possibly try and decode the message but use a default error message if it fails.
I like the idea of having this feature, but right now it doesn't exist. Should we remove it from the readme or add it back to the client?
Ideally the client could get the package name and version from the local pubspec.yaml if desired, but maybe that's outside the scope of what this package should do.
Reason being that package pubspec has key archive_url, but toMap and fromMap refer to achiveUrl.
Fix in pub_package_model.dart is:
@@ -73,7 +73,7 @@ class PackageVersion {
Map<String, dynamic> toMap() => {
'version': version,
'pubspec': pubspec.toJson(),
- 'archiveUrl': archiveUrl,
+ 'archive_url': archiveUrl,
'published': published.millisecondsSinceEpoch,
};
@@ -81,7 +81,7 @@ class PackageVersion {
version: map['version'] as String? ?? '',
pubspec:
PubSpec.fromJson(map['pubspec'] as Map<String, dynamic>? ?? {}),
- archiveUrl: map['archiveUrl'] as String? ?? '',
+ archiveUrl: map['archive_url'] as String? ?? '',
published: DateTime.parse(map['published'] as String? ?? ''),
);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.