initNet method
Future<void>
initNet({
- required String baseUrl,
- Directory? cacheDir,
- String cacheName = 'app_local_data',
- CacheMode baseCacheMode = CacheMode.ONLY_REQUEST,
- List<
Interceptor> ? interceptors, - BaseOptions? baseOptions,
- bool systemLog = false,
- CheckNetWork? baseCheckNet,
- List<
String> ? ignoreCacheKeys, - HiveCipher? encryptionCipher,
- Map<
String, dynamic> ? baseUrlEnv, - int cacheInvalidationTime = 365 * 24 * 60 * 60 * 1000,
- double debugWindowWidth = 800,
- double debugWindowHeight = 600,
Implementation
Future<void> initNet({
required String baseUrl,
Directory? cacheDir,
String cacheName = 'app_local_data',
CacheMode baseCacheMode = CacheMode.ONLY_REQUEST,
List<Interceptor>? interceptors,
BaseOptions? baseOptions,
bool systemLog = false,
CheckNetWork? baseCheckNet,
List<String>? ignoreCacheKeys,
HiveCipher? encryptionCipher,
Map<String, dynamic>? baseUrlEnv,
int cacheInvalidationTime = 365 * 24 * 60 * 60 * 1000,
double debugWindowWidth = 800,
double debugWindowHeight = 600
}) async {
LogUtil.init(systemLog: systemLog);
this._baseCheckNet = baseCheckNet;
this._baseCacheMode = baseCacheMode;
this._cacheInvalidationTime = cacheInvalidationTime;
this._baseIgnoreCacheKeys = ignoreCacheKeys;
debugWindow = ValueNotifier(Size(debugWindowWidth, debugWindowHeight));
if (baseOptions != null) {
_client?.options = baseOptions;
}
_client?.options.baseUrl = baseUrl;
if (interceptors != null) {
_client?.interceptors.addAll(interceptors);
}
if (baseUrlEnv != null && baseUrlEnv.isNotEmpty) {
_baseUrlEnv.addAll(baseUrlEnv);
}
if (RxNetPlatform.isWeb) {
this._baseCacheMode = CacheMode.ONLY_REQUEST;
LogUtil.v("RxNet does not support caching environments: web");
LogUtil.v("RxNet 不支持缓存的环境:web");
return;
}
await cacheManager.init(cacheDir, cacheName, encryptionCipher);
}