A Dart client for the Hacker News API. Works on Flutter, Server, and Web.
No need for an API key or anything, just create an instance of the client and fetch results!
// Create a client and pass in an http.Client. // - For Flutter & Server, use IOClient // - For Web, use BrowserClient final client = HackerNewsClient(IOClient()); // Fetch the top stories. Does not include all comments. final topStories = await client.topStories(); // Fetch the newest stories. Does not include all comments final newStories = await client.newStories(); // Fetch a story with all comments final newStories = await client.story(8863);
Features and bugs #
Please file feature requests and bugs at the issue tracker.
- Initial version of a a Hacker News Client for Dart
- Works on Flutter, Server, and Web
- Covered by tests
- Top Stories
- Best Stories
- New Stories
- Ask Hacker News
- Show Hacker News
- Story with all comments
- Poll with Options and all comments
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies: hacker_news_client: ^0.1.0
2. Install it
You can install packages from the command line:
$ pub get
$ flutter pub get
Alternatively, your editor might support
pub get or
flutter pub get.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Sep 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.5.0
- pana: 0.12.21
Detected platforms: Flutter, web, other
No platform restriction found in primary library
Health issues and suggestions
lib/src/client.dart. (-25 points)
lib/src/client.dart failed with 1 error:
line 74 col 30: The constructor 'List.generate' doesn't have type parameters.
lib/src/models/poll.g.dart. (-0.50 points)
lib/src/models/poll.g.dart reported 1 hint:
line 184 col 7: DO use curly braces for all flow control structures.
lib/src/models/poll_option.g.dart. (-0.50 points)
lib/src/models/poll_option.g.dart reported 1 hint:
line 131 col 7: DO use curly braces for all flow control structures.
Maintenance issues and suggestions
Support latest dependencies. (-30 points)
The version constraint in
pubspec.yaml does not support the latest published versions for 3 dependencies (
Package is getting outdated. (-15.62 points)
The package was last published 60 weeks ago.
Maintain an example. (-10 points)
Create a short demo in the
example/ directory to show how to use this package.
Common filename patterns include
hacker_news_client.dart. Packages with multiple examples should provide
For more information see the pub package layout conventions.
|Dart SDK||>=2.0.0-dev.50.0 <3.0.0|