RxNet class
create_user: zhengzaihong email:1096877329@qq.com create_date: 2022/8/9 create_time: 18:03 describe: 网络请求工具库,支持多种缓存模式 同一个CancelToken可以用于多个请求,当一个CancelToken取消时,所有使用该CancelToken的请求都会被取消。 日志输出:debug默认会输出日志到控制台, release不会输出日志到控制台
Network request tool library, supporting multiple caching modes The same CancelToken can be used for multiple requests. When a CancelToken is cancelled, all requests using that CancelToken will be cancelled. Log output: If debug is the default, log will be output to the console, if release is the default, log will not be output to the console
- Mixed-in types
Constructors
- RxNet.new()
-
factory
Properties
- client → Dio?
-
no setter
- collectLogs → bool
-
no setter
-
debugWindowSizeNotifier
↔ ValueNotifier<
Size> -
调试窗口大小
Debugging window size
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
-
logsNotifier
↔ ValueNotifier<
List< String> > -
收集的日志信息,用于界面呈现
Collected log information for interface presentation
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
addLogs(
String log) → void -
cacheLogToFile(
String filePath) → void - 这里提供一个收集日字的方法,便于后期排查 文件需要有写的权限,eg:xxx/xxx/log.txt
-
clearLogs(
) → void -
closeDebugWindow(
) → void -
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
inherited
-
getClient(
) → Dio? -
getDb(
) → RxNetDataBase? -
getHeaders(
) → Map< String, dynamic> -
init(
{required String baseUrl, Directory? cacheDir, String cacheName = 'app_local_data', List< Interceptor> ? interceptors, BaseOptions? baseOptions, bool useSystemPrint = false, CheckNetWork? baseCheckNet, List<String> ? ignoreCacheKeys, RequestCaptureError? requestCaptureError, CacheMode? baseCacheMode, HiveCipher? encryptionCipher, Map<String, dynamic> ? baseUrlEnv, int cacheInvalidationTime = 365 * 24 * 60 * 60 * 1000, double debugWindowWidth = 600, double debugWindowHeight = 500}) → Future<void> -
初始化公共属性
baseUrl
地址前缀baseUrl
address prefixinterceptors
基础拦截器interceptors
basic interceptor -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
readCache(
String key) → Future -
读取缓存
key
缓存key -
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
saveCache(
String key, dynamic value) → Future -
缓存
key
缓存keyvalue
缓存值 -
setCollectLogs(
bool collect) → void -
setEnv(
String env) → void -
切换环境
env
环境名称 key 例如:debug,test,release -
setHeaders(
Map< String, dynamic> header) → void - 设置全局请求头
-
showDebugWindow(
BuildContext context) → void -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- maxRetryCount ↔ int
-
最大重试次数
maximum number of retries
getter/setter pair
Static Methods
-
delete<
T> () → BuildRequest -
get<
T> () → BuildRequest -
patch<
T> () → BuildRequest -
post<
T> () → BuildRequest -
put<
T> () → BuildRequest