This class facilitates overriding HttpClient with a mock implementation. It should be extended by another class in client code with overrides that construct a mock implementation. The implementation in this base class defaults to the actual HttpClient implementation. For example:
// An implementation of the HttpClient interface
class MyHttpClient implements HttpClient {
MyHttpClient(SecurityContext? c);
@override
noSuchMethod(Invocation invocation) {
// your implementation here
}
}
void main() {
HttpOverrides.runZoned(() {
// Operations will use MyHttpClient instead of the real HttpClient
// implementation whenever HttpClient is used.
}, createHttpClient: (SecurityContext? c) => MyHttpClient(c));
} context. body in a fresh Zone using the overrides found in overrides. body in a fresh Zone using the provided overrides.
© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-io/HttpOverrides-class.html