DioApiService constructor
DioApiService(
- BuildContext? context, {
- BaseOptions baseOptions(
- BaseOptions baseOptions
- Dio initDio(
- Dio api
Implementation
DioApiService(BuildContext? context,
{BaseOptions Function(BaseOptions baseOptions)? baseOptions,
Dio Function(Dio api)? initDio}) {
_initDio = initDio;
_context = context;
if (baseOptions != null) {
BaseOptions baseOptionsFinal = BaseOptions();
this.baseOptions = baseOptions(baseOptionsFinal);
if (this.baseOptions?.baseUrl == null ||
this.baseOptions?.baseUrl == '') {
this.baseOptions?.baseUrl = baseUrl;
}
} else {
this.baseOptions = BaseOptions(
baseUrl: baseUrl,
headers: {
"Content-type": "application/json",
"Accept": "application/json",
},
connectTimeout: const Duration(seconds: 5),
);
}
init();
}