getUri method Null safety

Future<String> getUri(
  1. Uri url,
  2. {bool readCache = true,
  3. bool writeCache = true,
  4. Duration? ttl,
  5. Map<String, String> headers = const {},
  6. String defaultCharset(
    1. List<int>
    )?,
  7. String forcedCharset(
    1. List<int>
    )?}
)

Implementation

Future<String> getUri(
  Uri url, {
  bool readCache = true,
  bool writeCache = true,
  Duration? ttl,
  Map<String, String> headers = const {},
  String Function(List<int>)? defaultCharset,
  String Function(List<int>)? forcedCharset,
}) async {
  final cachedResp = (readCache || forceCache) ? getCache(url) : null;
  if (cachedResp != null) return cachedResp;
  final req = await _client.getUrl(url);
  headers.forEach((k, v) => req.headers.add(k, v));
  return _finishRequest(req, writeCache, defaultCharset, forcedCharset,
      (r) => setCache(url, r, ttl));
}