create method
Implementation
Future<void> create({required String baseURL}) async {
BaseOptions options = BaseOptions(
baseUrl: baseURL,
/*connectTimeout: 180000,
receiveTimeout: 180000,*/
connectTimeout: const Duration(seconds: 60),
receiveTimeout: const Duration(seconds: 60),
);
dio = Dio(options);
dio.interceptors.add(InterceptorsWrapper(
onRequest: (options, handler) {
if (showPrints) {
printer("= = = Shurjopay Request = = =");
printer(options.headers);
printer(options.contentType);
printer(options.extra);
printer("${options.baseUrl}${options.path}");
printer(options.data);
}
return handler.next(options);
},
onError: (DioException error, handler) async {
if (showPrints) {
printer("= = = Shurjopay Error Response = = =");
printer('Error Response: ${error.response}');
printer('Error Message: ${error.message}');
printer('Error Type: ${error.type}');
}
return handler.next(error);
},
onResponse: (response, handler) {
if (showPrints) {
printer("= = = Shurjopay Success Response = = =");
printer(response.headers);
printer(
response.requestOptions.baseUrl + response.requestOptions.path);
printer(response.statusCode);
printer(response.extra);
printer(json.encode(response.data));
}
return handler.next(response);
},
));
}