network 0.0.2+1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new64
Logo

Package including hooks for easy works with http package in dart.

Pub

Key FeaturesGetting StartedTodoCredits

Key Features #

  • Simple hooks for get / post
  • Specify response type (blob\json api)

Getting Started #

Import

import 'package:network/network.dart'

Get request to API:

main() async {
  final getResponse = await network.get<network.JsonApiResponse>(
      'https://jsonplaceholder.typicode.com/todos/1');
  print(getResponse.toMap['title']);
}

Get request Blob:

main() async {
  final blobResponse = await network.get(
      'https://via.placeholder.com/300');
  print(blobResponse.bytes);
}

And... api reference available here

TODO #

  • [x] Get
  • [x] Post
  • [x] Delete
  • [x] Put
  • [ ] Decorators (#1)

Credits #

This software uses the following open source packages:

0.0.2 #

  • Removed debug print
  • Added hooks for delete & put http methods

0.0.1 #

  • Initial release

example/main.dart

import 'package:network/network.dart' as network;

main() async {
  final getResponse = await network.get<network.JsonApiResponse>(
      'https://jsonplaceholder.typicode.com/todos/1');
  print(getResponse.toMap['title']);

  // Post request to api
  final postResponse = await network.post<network.JsonApiResponse>(
      'https://jsonplaceholder.typicode.com/todos',
      body: {'title': 'test'});
  print(postResponse.toMap['id']);

  // Or post binary
  // await network.post<network.JsonApiResponse>(
  //   'https://jsonplaceholder.typicode.com/todos', body: [0,0,0,0,0],
  // jsonBody: false);

  /// Handle exceptions
  try {
    await network.get('https://jsonplaceholder.typicode.com/todos/202');
  } on network.NetworkException catch (error) {
    print('Network exception called, status code: ${error.code}');
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  network: ^0.0.2+1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:network/network.dart';
  
Version Uploaded Documentation Archive
0.0.2+1 Mar 12, 2019 Go to the documentation of network 0.0.2+1 Download network 0.0.2+1 archive
0.0.2 Mar 12, 2019 Go to the documentation of network 0.0.2 Download network 0.0.2 archive
0.0.1 Mar 1, 2019 Go to the documentation of network 0.0.1 Download network 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
33
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
64
Learn more about scoring.

We analyzed this package on Mar 12, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:network/network.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
http ^0.12.0+1 0.12.0+1
Transitive dependencies
async 2.0.8
charcode 1.1.2
collection 1.14.11
http_parser 3.1.3
meta 1.1.7
path 1.6.2
source_span 1.5.5
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
test ^1.5.3