http 0.11.3+16

  • Installing
  • Versions
  • 99


A composable, Future-based library for making HTTP requests.

This package contains a set of high-level functions and classes that make it easy to consume HTTP resources. It's platform-independent, and can be used on both the command-line and the browser. Currently the global utility functions are unsupported on the browser; see "Using on the Browser" below.


The easiest way to use this library is via the top-level functions, although they currently only work on platforms where dart:io is available. They allow you to make individual HTTP requests with minimal hassle:

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

var url = "";, body: {"name": "doodle", "color": "blue"})
    .then((response) {
  print("Response status: ${response.statusCode}");
  print("Response body: ${response.body}");

If you're making multiple requests to the same server, you can keep open a persistent connection by using a Client rather than making one-off requests. If you do this, make sure to close the client when you're done:

var client = new http.Client();
    body: {"name": "doodle", "color": "blue"})
  .then((response) => client.get(response.bodyFields['uri']))
  .then((response) => print(response.body))

You can also exert more fine-grained control over your requests and responses by creating Request or StreamedRequest objects yourself and passing them to Client.send.

This package is designed to be composable. This makes it easy for external libraries to work with one another to add behavior to it. Libraries wishing to add behavior should create a subclass of BaseClient that wraps another Client and adds the desired behavior:

class UserAgentClient extends http.BaseClient {
  final String userAgent;
  final http.Client _inner;

  UserAgentClient(this.userAgent, this._inner);

  Future<StreamedResponse> send(BaseRequest request) {
    request.headers['user-agent'] = userAgent;
    return _inner.send(request);

Using on the Browser

The HTTP library can be used on the browser via the BrowserClient class in package:http/browser_client.dart. This client translates requests into XMLHttpRequests. For example:

import 'dart:async';
import 'package:http/browser_client.dart';

main() async {
  var client = new BrowserClient();
  var url = '/whatsit/create';
  var response =
      await, body: {'name': 'doodle', 'color': 'blue'});
  print('Response status: ${response.statusCode}');
  print('Response body: ${response.body}');


  • Stop depending on the stack_trace package.


  • Declare support for async 2.0.0.


  • Remove single quote ("'" - ASCII 39) from boundary characters. Causes issues with Google Cloud Storage.


  • remove boundary characters that package:http_parser cannot parse.


  • Don't quote the boundary header for MultipartRequest. This is more compatible with server quirks.


  • Fix the SDK constraint to only include SDK versions that support importing dart:io everywhere.


  • Stop using dart:mirrors.


  • Remove an extra newline in multipart chunks.


  • Properly specify Content-Transfer-Encoding for multipart chunks.


  • Declare compatibility with http_parser 3.0.0.


  • Fix one more strong mode warning in http/testing.dart.


  • Fix some lingering strong mode warnings.


  • Fix all strong mode warnings.


  • Support http_parser 2.0.0.


  • Require Dart SDK >= 1.9.0

  • Eliminate many uses of Chain.track from the stack_trace package.


  • Support http_parser 1.0.0.


  • Add a Client.patch shortcut method and a matching top-level patch method.


  • Add a BrowserClient.withCredentials property.


  • Properly namespace an internal library name.


  • Widen the version constraint on unittest.


  • Widen the version constraint for stack_trace.


  • Expose the IOClient class which wraps a dart:io HttpClient.


  • Fix a bug in handling errors in decoding XMLHttpRequest responses for BrowserClient.


  • The package no longer depends on dart:io. The BrowserClient class in package:http/browser_client.dart can now be used to make requests on the browser.

  • Change MultipartFile.contentType from dart:io's ContentType type to http_parser's MediaType type.

  • Exceptions are now of type ClientException rather than dart:io's HttpException.


  • Make BaseRequest.contentLength and BaseResponse.contentLength use null to indicate an unknown content length rather than -1.

  • The contentLength parameter to new BaseResponse is now named rather than positional.

  • Make request headers case-insensitive.

  • Make MultipartRequest more closely adhere to browsers' encoding conventions.

1. Depend on it

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

  http: "^0.11.3+16"

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/http.dart';
Version Uploaded Documentation Archive
0.11.3+16 Oct 13, 2017 Go to the documentation of http 0.11.3+16 Download http 0.11.3+16 archive
0.11.3+15 Sep 27, 2017 Go to the documentation of http 0.11.3+15 Download http 0.11.3+15 archive
0.11.3+14 Jul 20, 2017 Go to the documentation of http 0.11.3+14 Download http 0.11.3+14 archive
0.11.3+13 Mar 30, 2017 Go to the documentation of http 0.11.3+13 Download http 0.11.3+13 archive
0.11.3+12 Mar 7, 2017 Go to the documentation of http 0.11.3+12 Download http 0.11.3+12 archive
0.11.3+11 Mar 6, 2017 Go to the documentation of http 0.11.3+11 Download http 0.11.3+11 archive
0.11.3+9 Jul 19, 2016 Go to the documentation of http 0.11.3+9 Download http 0.11.3+9 archive
0.11.3+8 Jul 6, 2016 Go to the documentation of http 0.11.3+8 Download http 0.11.3+8 archive
0.11.3+7 May 5, 2016 Go to the documentation of http 0.11.3+7 Download http 0.11.3+7 archive
0.11.3+6 May 4, 2016 Go to the documentation of http 0.11.3+6 Download http 0.11.3+6 archive

All 101 versions...


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


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


Detected platforms: Flutter, web, other

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


  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • 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.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use http.dart.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.23.0 <2.0.0
async >=1.10.0 <3.0.0 2.0.3
collection ^1.5.0 1.14.5
http_parser >=0.0.1 <4.0.0 3.1.1
path >=0.9.0 <2.0.0 1.5.1
Transitive dependencies
charcode 1.1.1
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
unittest >=0.9.0 <0.12.0