get static method

Future<Response> get(
  1. Uri url, {
  2. Map<String, String>? headers,
  3. Duration? timeout,
})

Implementation

static Future<Response> get(Uri url,
    {Map<String, String>? headers, Duration? timeout}) async {
  var newHeader = _defaultHeaders(headers);
  final effectiveTimeout = timeout ?? requestTimeout;
  var client = http.Client();
  try {
    return await client.get(url, headers: newHeader).timeout(effectiveTimeout,
        onTimeout: () {
      client.close();
      throw TimeoutException("GET request timed out.", effectiveTimeout);
    });
  } finally {
    client.close();
  }
}