hacker_news_client 0.1.0

hacker_news_client #

Build Status codecov

A Dart client for the Hacker News API. Works on Flutter, Server, and Web.

Usage #

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.

0.1.0 #

  • Initial version of a a Hacker News Client for Dart
  • Works on Flutter, Server, and Web
  • Covered by tests
  • Supports:
    • Top Stories
    • Best Stories
    • New Stories
    • Jobs
    • Ask Hacker News
    • Show Hacker News
    • Story with all comments
    • Poll with Options and all comments
    • User

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:

with pub:


$ pub get

with Flutter:


$ 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:


import 'package:hacker_news_client/hacker_news_client.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
56
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
4
Overall:
Weighted score of the above. [more]
18
Learn more about scoring.

We analyzed this package on Feb 13, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

Health issues and suggestions

Fix lib/src/client.dart. (-25 points)

Analysis of lib/src/client.dart failed with 1 error:

line 74 col 30: The constructor 'List.generate' doesn't have type parameters.

Fix lib/src/models/poll.g.dart. (-16.93 points)

Analysis of lib/src/models/poll.g.dart reported 37 hints, including:

line 17 col 37: Unnecessary new keyword.

line 39 col 41: Avoid const keyword.

line 39 col 48: Avoid const keyword.

line 43 col 41: Avoid const keyword.

line 43 col 48: Avoid const keyword.

Fix lib/src/models/serializers.g.dart. (-14.39 points)

Analysis of lib/src/models/serializers.g.dart reported 31 hints, including:

line 17 col 30: Unnecessary new keyword.

line 27 col 37: Avoid const keyword.

line 27 col 44: Avoid const keyword.

line 28 col 17: Unnecessary new keyword.

line 30 col 37: Avoid const keyword.

Fix additional 8 files with analysis or formatting issues. (-54.78 points)

Additional issues in the following files:

  • lib/src/models/story.g.dart (23 hints)
  • lib/src/models/comment.g.dart (22 hints)
  • lib/src/models/summary.g.dart (17 hints)
  • lib/src/models/user.g.dart (15 hints)
  • lib/src/models/poll_option.g.dart (13 hints)
  • lib/src/models/job.g.dart (12 hints)
  • lib/src/models/story_type.g.dart (10 hints)
  • lib/src/models/serializers.dart (2 hints)

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 (built_collection, built_value, http).

Package is getting outdated. (-56.44 points)

The package was last published 81 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 main.dart, example.dart, and hacker_news_client.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.50.0 <3.0.0
built_collection ^3.1.1 3.1.3 4.3.2
built_value ^5.5.3 5.5.5 7.0.9
http ^0.11.3+17 0.11.3+17 0.12.0+4
Transitive dependencies
async 2.4.0
charcode 1.1.3
collection 1.14.12
fixnum 0.10.11
http_parser 3.1.3
matcher 0.12.6
meta 1.1.8
path 1.6.4
quiver 2.1.2+1
source_span 1.6.0
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
build_runner ^0.9.0
built_value_generator ^5.5.3
coverage 0.12.1
test ^1.0.0