FlutterNetwork constructor
FlutterNetwork({
- required String baseUrl,
- Future<
String?> tokenCallback()?, - VoidCallback? onUnAuthorizedError,
- CacheOptions? cacheOptions,
- RetryInterceptor? retryInterceptor,
- int connectionTimeout = 30000,
- int receiveTimeout = 30000,
Implementation
factory FlutterNetwork({
required String baseUrl,
Future<String?> Function()? tokenCallback,
VoidCallback? onUnAuthorizedError,
CacheOptions? cacheOptions,
RetryInterceptor? retryInterceptor,
int connectionTimeout = 30000,
int receiveTimeout = 30000,
}) {
_instance.baseUrl = baseUrl;
_instance.tokenCallback = tokenCallback;
_instance.onUnAuthorizedError = onUnAuthorizedError ?? () {};
_instance.connectionTimeout = connectionTimeout;
_instance.receiveTimeout = receiveTimeout;
_instance.cacheOptions = cacheOptions;
_instance.retryInterceptor = retryInterceptor;
BaseOptions options = BaseOptions(
baseUrl: baseUrl,
connectTimeout: Duration(milliseconds: connectionTimeout),
receiveTimeout: Duration(milliseconds: receiveTimeout),
);
_instance._dio = Dio(options);
return _instance;
}