getCachedResponseText method

Future<String?> getCachedResponseText(
  1. RequestApi request
)

Implementation

Future<String?> getCachedResponseText(RequestApi request) async {
  try {
    FileInfo? fileInfo = await getFileFromCache(
        "${request.uri.toString()}-${json.encode(request.body)}-${json.encode(request.bodyJson)}}");
    if (fileInfo == null || !fileInfo.file.existsSync()) return null;

    List<int> byteList = fileInfo.file.readAsBytesSync();
    return utf8.decode(byteList);
  } catch (_) {
    return null;
  }
}