initDio static method
Implementation
static Dio initDio(String partUrl, bool isMultipart) {
var dio = Dio();
Map<String, String> headers;
String acceptHeader;
String contentTypeHeader;
// dio.interceptors.add(InterceptorsWrapper(onError: (DioError error , handler) async {
// if (error.response?.statusCode == 403 ||
// error.response?.statusCode == 401) {
// print("handle un");
// await refreshToken();
// return _retry(error.requestOptions);
// }
// return error.response;
// }));
acceptHeader = 'application/json';
contentTypeHeader =
isMultipart ? 'multipart/form-data' : 'application/json';
headers = {
HttpHeaders.acceptHeader: acceptHeader,
HttpHeaders.contentTypeHeader: contentTypeHeader,
};
final fullUrl = '$baseUrl/$partUrl';
//debugPrint(fullUrl);
// debugPrint(Injector.prefs.getString(PrefKeys.token));
BaseOptions options = BaseOptions(baseUrl: fullUrl, headers: headers);
dio.options = options;
return dio;
}