get method

Future<Response> get(
  1. Uri uri, {
  2. Map<String, String>? headers,
  3. bool useCache = true,
})

Implementation

Future<http.Response> get(Uri uri,
    {Map<String, String>? headers, bool useCache = true}) async {
  String path = "${uri.path}?${uri.query}";

  try {
    final response = await http.get(uri, headers: headers);
    if (useCache) _store.write(path, response.json);
    return response;
  } catch (e) {
    if (useCache && !blackList.contains(uri.path)) {
      Map<String, dynamic>? cache = _store.read<Map<String, dynamic>>(path);
      if (cache != null) return cache.response;
    }
    throw e;
  }
}