Where did IOClient go in the Dart http package?

2019-07-27 09:24发布

问题:

I'm working on making http requests from a Flutter project. I have seen several answers refer to IOClient. For example, here and here and here. However, the following imports do not work (though they apparently used to):

import 'package:http/http.dart';
import 'package:http/http.dart' show IOClient;

Instead, the second one gives the error message:

The library 'package:http/http.dart' doesn't export a member with the shown name 'IOClient'.

How do I import IOClient?

回答1:

IOClient is still in the http package but it is no longer in the http library. It has been extracted into its own library as io_client. You can import it like this:

import 'package:http/io_client.dart';