init static method
void
init({})
Implementation
static void init({
int timeout = 15,
String baseUrl = "",
String? codeField,
String? dataField,
String? msgField,
String? successCode,
String? tokenHeaderName ,
Function? tokenCreator,
Map<String, dynamic>? header,
Function(dynamic)? onHookResponse,
}) {
_dio ??= Dio();
_dio!.options.sendTimeout = Duration(seconds: timeout);
_dio!.options.connectTimeout = Duration(seconds: timeout);
_dio!.options.receiveTimeout = Duration(seconds: timeout);
_dio!.options.baseUrl = baseUrl;
_dio!.interceptors.add(HttpFormatter());
_dio!.interceptors.add(TokenInterceptor(tokenHeaderName ?? _tokenHeader, tokenCreator, onHookResponse: onHookResponse));
if(ObjectUtil.isNotEmpty(codeField)) _codeField = codeField!;
if(ObjectUtil.isNotEmpty(dataField)) _dataField = dataField!;
if(ObjectUtil.isNotEmpty(msgField)) _msgField = msgField!;
if(ObjectUtil.isNotEmpty(successCode)) _successCode = successCode!;
if(header!=null) _dio?.options.headers.addAll(header);
}