title: Choosing between package:html, dart:html, dart:io (class HttpClient) and package:http APIs to fetch HTTP resources
body: <p>I realized that currently there are at least three "official" Dart libraries that allow me to perform a HTTP request. What is more, three of those libraries (dart:io (class HttpClient), package:http and dart:html) have each a different, incompatible API.</p>
  
  <p>As of today, package:html does not offer this functionality, but on its GitHub page I found it aims for 100% API compatibility with dart:html, so these methods will be added there eventually.</p>
  
  <p>Which package provides the most future proof and platform independent API to issue a HTTP request in Dart?</p>
  
  <p>Is it package:http?</p>
  
  <pre><code>import 'package:http/http.dart' as http;
  
  var url = "http://example.com";
  http.get(url)
      .then((response) {
    print("Response status: ${response.statusCode}");
    print("Response body: ${response.body}");
  });
  </code></pre>
  
  <p>Is it dart:html/package:html?</p>
  
  <pre><code>import 'dart:html';
  
  HttpRequest.request('/example.json')
    .then((response) {
        print("Response status: ${response.status}");
        print("Response body: ${response.response}");
  });
  </code></pre>
  
  <p>Or dart:io?</p>
  
  <pre><code>import 'dart:io';
  
  var client = new HttpClient();
  client.getUrl(Uri.parse("http://www.example.com/"))
      .then((HttpClientRequest request) {
        // Optionally set up headers...
        // Optionally write to the request object...
        // Then call close.
        ...
        return request.close();
      })
      .then((HttpClientResponse response) {
        print("Response status: ${response.statusCode}");
        print("Response body:");
        response.transform(UTF8.decoder).listen((contents) {
          print(contents);
        });
      });
  </code></pre>
  
  <p>Let's say I want to cover Android too. That adds package:sky in the mix as well (<a href="https://github.com/domokit/sky_sdk/" rel="nofollow">https://github.com/domokit/sky_sdk/</a>). I admit that this is not "official" Google library.</p>
  
  <pre><code>import 'package:sky/framework/net/fetch.dart';
  
  Response response = await fetch('http://example.com');
  print(response.bodyAsString());
  </code></pre>
  
  <p>What is (going to be) a regular product is <a href="https://www.youtube.com/watch?v=t8xdEO8LyL8" rel="nofollow">https://www.youtube.com/watch?v=t8xdEO8LyL8</a>. I wonder what <strong>their</strong> HTTP Request story is going to be. Something tells me it will be yet another different beast from all we have seen so far.</p>