createClient method

HttpClient createClient({
  1. String? baseUrl,
  2. Map<String, String> defaultHeaders = const {},
  3. List<HttpInterceptor> interceptors = const [],
  4. Duration? timeout,
})

Creates a borrowed client. The test owns this controller and must close it.

Implementation

HttpClient createClient(
    {String? baseUrl,
    Map<String, String> defaultHeaders = const {},
    List<HttpInterceptor> interceptors = const [],
    Duration? timeout}) {
  if (_closed) throw StateError('Testing controller closed.');
  final options = HttpClientRegistrationBuilder(
          baseUrl: baseUrl,
          defaultHeaders: defaultHeaders,
          interceptors: interceptors,
          timeout: timeout)
      .build()
      .options;
  return HttpClientService(transport: this, options: options);
}