get method
Implementation
@override
Future<http.Response?> get(String key) async {
final file = File('${_cacheDir.path}/$key');
if (await file.exists()) {
final content = await file.readAsString();
final json = jsonDecode(content);
final headers = Map<String, String>.from(json['headers']);
final body = json['body'];
final cacheTime = DateTime.parse(json['cache-time']);
return _isValid(cacheTime)
? http.Response(body, 200, headers: headers)
: null;
}
return null;
}