flutter cache json
import 'package:dio/dio.dart';
class CacheInterceptor extends Interceptor {
CacheInterceptor();
var _cache = new Map<Uri, Response>();
@override
onRequest(RequestOptions options) async {
return options;
}
@override
onResponse(Response response) async {
_cache[response.request.uri] = response;
}
@override
onError(DioError e) async{
print('onError: $e');
if (e.type == DioErrorType.CONNECT_TIMEOUT || e.type == DioErrorType.DEFAULT) {
var cachedResponse = _cache[e.request.uri];
if (cachedResponse != null) {
return cachedResponse;
}
}
return e;
}
}
Also in JavaScript:
- loopback float type
- node import all functions from file
- js class
- node node_modules/protractor/bin/webdriver-manager update
- how to fetch first 10 characters of a string in node js
- push values to state array class react
- react how to scroll to element
- js remove special characters
- javascript string ends with
- javascript regex single line
- trim text and add ... js
- left_field in jsgrid
- 'React' must be in scope when using JSX react/react-in-jsx-scope
- javascript null check
- how to read all files in a folder in node js
- rails call multiple variable format json
- loading page for all ajax call in jquery 3.3.1
- javascript array to csv string
- print all variables defined javascript
- js scrolling in div
- adding growl delete notifications in vanilla js
- javascript ascii to hex
- disable autocomplete in react fields
- js scroll to id