http_client_helper 0.1.4

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 56

http_client_helper

pub package

A Flutter plugin for http request with cancel and retry fuctions.

Usage

To use this plugin, add http_client_helper as a dependency in your pubspec.yaml file.

Example

  cancellationToken = new CancellationToken();
    try {
      await HttpClientHelper.get(url,
              cancelToken: cancellationToken,
              millisecondsDelay: 1000,
              retries: 10)
          .then((response) {
        setState(() {
          msg = response.body;
        });
      });
    } on OperationCanceledError catch (e) {
      setState(() {
        msg = "cancel";
      });
    } catch (e) {

    }

If you need other method of http, you can do it with RetryHelper and CancellationToken as you wish. as follow

static Future<Response> get(url,
      {Map<String, String> headers,
      CancellationToken cancelToken,
      int millisecondsDelay = 100,
      int retries = 3}) async {
    cancelToken?.throwIfCancellationRequested();
    return await RetryHelper.tryRun<Response>(() {
      return CancellationTokenSource.register(
          cancelToken, _httpClient.get(url, headers: headers));
    },
        cancelToken: cancelToken,
        millisecondsDelay: millisecondsDelay,
        retries: retries);
  }

Please see the example app of this plugin for a full example.

[0.1.4]

  • remove map to string for post

[0.1.3]

  • make all http_client_helper darts as library http_client_helper

[0.1.2]

  • Fix retries for retry helper.

[0.1.1]

  • Handle map body.

[0.1.0]

  • Upgrade Some Commments.

[0.0.1]

  • Initial Open Source release.

example/README.md

example

A new Flutter application.

Getting Started

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

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


dependencies:
  http_client_helper: ^0.1.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support 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:http_client_helper/http_client_helper.dart';
  
Version Uploaded Documentation Archive
0.1.4 Dec 12, 2018 Go to the documentation of http_client_helper 0.1.4 Download http_client_helper 0.1.4 archive
0.1.3 Dec 10, 2018 Go to the documentation of http_client_helper 0.1.3 Download http_client_helper 0.1.3 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
15
Health:
Code health derived from static analysis. [more]
96
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
56
Learn more about scoring.

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

  • Dart: 2.1.0
  • pana: 0.12.10
  • Flutter: 1.1.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/src/retry_helper.dart. (-2.96 points)

Analysis of lib/src/retry_helper.dart reported 6 hints, including:

line 5 col 10: This function has a return type of 'Future<T>', but doesn't end with a return statement.

line 5 col 10: The class 'Future' was not exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 6 col 5: The class 'Future' was not exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 15 col 21: Avoid using braces in interpolation when not needed.

line 20 col 23: The stack trace variable 'stackTrace' isn't used and can be removed.

Fix lib/src/cancellation_token.dart. (-1 points)

Analysis of lib/src/cancellation_token.dart reported 2 hints:

line 2 col 8: Unused import: 'package:http/http.dart'.

line 23 col 9: Use isNotEmpty for Iterables and Maps.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
http ^0.12.0 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.6 1.1.7
path 1.6.2
sky_engine 0.0.99
source_span 1.5.1
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test