title: How to point to localhost:8000 with the Dart http package in Flutter?
body: <p>I'm following the <a href="https://flutter.io/networking/" rel="noreferrer">Flutter Networking/HTTP tutorial</a> to do a GET request to a server running on my localhost:8000. Visiting my localhost via my browser works fine. My code looks like this:</p>
  
  <pre><code>var url = 'http://localhost:8000';
  Future&lt;String&gt; getUnits(String category) async {
      var response = await httpClient.get('$url/$category');
      return response.body;
  }
  </code></pre>
  
  <p>This works fine when I point to any real URL, such as <code>https://example.com</code>, but when I point to <code>https://localhost:8000</code> or <code>https://localhost</code> (or any variations of these), I get an error starting with:</p>
  
  <pre><code>E/flutter ( 4879): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
  E/flutter ( 4879): SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 47060
  E/flutter ( 4879): #0      IOClient.send (package:http/src/io_client.dart:30:23)
  </code></pre>
  
  <p>The port in the error above changes each time I reload the app. I looked in the <a href="https://github.com/dart-lang/http" rel="noreferrer">http package code</a> and it doesn't seem like there is a way to specify the port for the URL. How do I point to my localhost?</p>