get static method

Future<Response> get(
  1. String url, {
  2. Map<String, String>? headers,
  3. Duration timeout = const Duration(seconds: 30),
})

GET 请求

Implementation

static Future<http.Response> get(
  String url, {
  Map<String, String>? headers,
  Duration timeout = const Duration(seconds: 30),
}) async {
  _logRequest('GET', url, headers: headers);

  try {
    final response = await http
        .get(Uri.parse(url), headers: headers)
        .timeout(timeout);

    _logResponse('GET', url, response);
    return response;
  } catch (e) {
    _logError('GET', url, e);
    rethrow;
  }
}