Skip to content

Make package:http/http.dart support all platforms #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 13, 2018

Conversation

jakemac53
Copy link
Contributor

@jakemac53 jakemac53 commented Sep 12, 2018

Fixes #22

Adds config specific imports to make package:http/http.dart support all platforms, and allow the Client factory constructor to return a valid Client for the web platform.

This should eliminate almost all need for the platform specific imports for consumers, although it does also add the io_client.dart public import.

Passes presubmit internally, with edits in only 3 files (they use the IoClient constructor directly, and pass in an HttpClient). Externally build_runner now supports config specific imports as well, I am currently working on validating everything works as expected there with this change.

New Features

  • The regular Client factory constructor is now usable anywhere that dart:io
    or dart:html are available, and will give you an IoClient or
    BrowserClient respectively.
  • The package:http/http.dart import is now safe to use on the web (or
    anywhere that either dart:io or dart:html are available).

Breaking Changes

  • In order to use or reference the IoClient directly, you will need to import
    the new package:http/io_client.dart import. This is typically only necessary
    if you are passing a custom HttpClient instance to the constructor, in which
    case you are already giving up support for web.

@zoechi
Copy link

zoechi commented Sep 12, 2018

The environment constraint lower limit is correct to support conditional imports?

@jakemac53
Copy link
Contributor Author

jakemac53 commented Sep 12, 2018

The environment constraint lower limit is correct to support conditional imports?

Technically, yes. It has been supported by the language and vm/dart2js for some time. We only recently actually had support in build systems and things, but we can't express that dependency unfortunately (ideally, we would be able to say if you have a dependency on build_runner, it must be >x.x.x (which supports these imports), but we can't express that).

@nex3
Copy link
Member

nex3 commented Sep 12, 2018

I'm swamped with Sass work and it looks like Nate has this review in hand, so I'm going to remove myself.

@nex3 nex3 removed their request for review September 12, 2018 19:49
@natebosch
Copy link
Member

I think this might also close out #22

@jakemac53 jakemac53 merged commit 0eb481b into dart-lang:master Sep 13, 2018
@jakemac53 jakemac53 deleted the use-config-specific-imports branch September 13, 2018 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants