http_client 0.3.1

  • Example
  • Installing
  • Versions
  • 86

Platform-independent HTTP client

A platform-independent HTTP client API supporting browser, console, and curl (for SOCKS proxy). Planned platforms: Fetch API, node_io.


To develop your platform-agnostic library, use only the base import:

import 'package:http_client/http_client.dart' as http;

class MyServiceClient {
  final http.Client httpClient;

For console apps:

import 'package:http_client/console.dart' as http;

main() async {
  http.Client client = new http.ConsoleClient();
  // use the client, eg.:
  // new MyServiceClient(client)
  await client.close();

For browser use, only change the first import:

import 'package:http_client/browser.dart' as http;

main() {
  http.Client client = new http.BrowserClient();
  // use the client, eg.:
  // new MyServiceClient(client)
  await client.close();



  • Added http proxy option to the console client.


  • Removed dependency on http package.


  • Add executor support to rate-limit the clients.


  • Add curl support.


Breaking changes:

  • instead of exporting the http package, http_client provides its own API

    • console and browser clients continue to use the http package
    • preparation to support node_io for apps that want to be packaged as a single binary (e.g. .exe)
    • preparation to support the Fetch API (e.g. in service workers)
  • removed the awkward newHttpClient() methods.


  • Exporting classes from the http package (version: ^0.1.13).


  • Exporting streaming request and response.


import 'dart:async';
import 'package:http_client/console.dart';

Future main() async {
  final client = new ConsoleClient();
  final rs = await client.send(new Request('GET', ''));
  final textContent = await rs.readAsString();
  await client.close();

1. Depend on it

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

  http_client: "^0.3.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 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/http_client.dart';
Version Uploaded Documentation Archive
0.3.1 Feb 12, 2018 Go to the documentation of http_client 0.3.1 Download http_client 0.3.1 archive
0.3.0 Dec 2, 2017 Go to the documentation of http_client 0.3.0 Download http_client 0.3.0 archive
0.2.2 Apr 15, 2017 Go to the documentation of http_client 0.2.2 Download http_client 0.2.2 archive
0.2.1 Apr 8, 2017 Go to the documentation of http_client 0.2.1 Download http_client 0.2.1 archive
0.2.0 Mar 24, 2017 Go to the documentation of http_client 0.2.0 Download http_client 0.2.0 archive
0.1.0+1 Mar 8, 2017 Go to the documentation of http_client 0.1.0+1 Download http_client 0.1.0+1 archive
0.1.0 Mar 7, 2017 Go to the documentation of http_client 0.1.0 Download http_client 0.1.0 archive


We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6


Describes how popular the package is relative to other packages. [more]
73 / 100
Code health derived from static analysis. [more]
98 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, web, other

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


  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 4 hints.

    Strong-mode analysis of lib/http_client.dart gave the following hint:

    line: 40 col: 24
    'UTF8' is deprecated and shouldn't be used.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.0 <2.1.0
executor >=1.0.0 <2.0.0 1.0.0