get static method

Future<Response?> get(
  1. Uri url, {
  2. Map<String, String>? headers,
  3. CancellationToken? cancelToken,
  4. int retries = 3,
  5. Duration? timeLimit,
  6. Duration timeRetry = const Duration(milliseconds: 100),
  7. FutureOr<Response> onTimeout()?,
})

Implementation

static Future<Response?> get(
  Uri url, {
  Map<String, String>? headers,
  CancellationToken? cancelToken,
  int retries = 3,
  Duration? timeLimit,
  Duration timeRetry = const Duration(milliseconds: 100),
  FutureOr<Response> Function()? onTimeout,
}) async {
  cancelToken?.throwIfCancellationRequested();
  return await RetryHelper.tryRun<Response>(
    () {
      return CancellationTokenSource.register(
        cancelToken,
        timeLimit == null
            ? _httpClient.get(
                url,
                headers: headers,
              )
            : _httpClient
                .get(
                  url,
                  headers: headers,
                )
                .timeout(
                  timeLimit,
                  onTimeout: onTimeout,
                ),
      );
    },
    cancelToken: cancelToken,
    timeRetry: timeRetry,
    retries: retries,
  );
}