HttpService constructor

HttpService({
  1. Client? client,
  2. bool? ownsClient,
  3. Config? config,
  4. AuthTokenProvider? tokenProvider,
  5. Duration timeout = defaultTimeout,
  6. Duration uploadTimeout = defaultUploadTimeout,
})

Every dependency is injectable so the transport can be exercised without a server. client also lets an application supply its own - one with certificate pinning, a proxy, or request logging.

Implementation

HttpService({
  http.Client? client,
  bool? ownsClient,
  Config? config,
  AuthTokenProvider? tokenProvider,
  Duration timeout = defaultTimeout,
  Duration uploadTimeout = defaultUploadTimeout,
}) : _client = client ?? http.Client(),
     _ownsClient = ownsClient ?? (client == null),
     config = config ?? Config(),
     _tokenProvider = tokenProvider,
     _timeout = timeout,
     _uploadTimeout = uploadTimeout;