RxNetConfigBuilder class

RxNetConfig Builder 类

提供流式 API 来构建 RxNetConfig 实例。

final config = RxNetConfig.builder()
  .baseUrl("https://api.example.com")
  .adapter(DioAdapter())
  .cacheMode(CacheMode.CACHE_EMPTY_OR_EXPIRED_THEN_REQUEST)
  .addInterceptor(RxNetLogAdapterInterceptor())
  .cacheInvalidationTime(60 * 1000) // 1 分钟
  .build();

Constructors

RxNetConfigBuilder()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

adapter(NetworkAdapter adapter) → RxNetConfigBuilder
设置网络适配器
addInterceptor(AdapterInterceptor interceptor) → RxNetConfigBuilder
添加拦截器
baseOptions(AdapterBaseOptions options) → RxNetConfigBuilder
设置适配器无关的全局请求默认配置(推荐)
baseUrl(String url) → RxNetConfigBuilder
设置基础 URL
baseUrlEnv(Map<String, dynamic> env) → RxNetConfigBuilder
设置多环境基础 URL
build() → RxNetConfig
构建 RxNetConfig 实例
cacheEvictionPolicy(CacheEvictionPolicy policy) → RxNetConfigBuilder
设置缓存淘汰策略
cacheInvalidationTime(int milliseconds) → RxNetConfigBuilder
设置缓存时效(毫秒)
cacheMaxSize(int size) → RxNetConfigBuilder
设置缓存最大条目数(0 表示不限制)
cacheMode(CacheMode mode) → RxNetConfigBuilder
设置缓存策略
cacheName(String name) → RxNetConfigBuilder
设置缓存文件名
cachePath(String path) → RxNetConfigBuilder
设置缓存目录路径
checkNetwork(CheckNetWork check) → RxNetConfigBuilder
设置网络检测回调
databaseName(String name) → RxNetConfigBuilder
设置数据库名称
debug(bool enable) → RxNetConfigBuilder
设置调试模式
debugWindowSize(double width, double height) → RxNetConfigBuilder
设置调试窗口大小
ignoreCacheKeys(List<String> keys) → RxNetConfigBuilder
设置忽略缓存的参数 key
interceptors(List<AdapterInterceptor> interceptors) → RxNetConfigBuilder
设置拦截器列表(覆盖)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
systemLog(bool enable) → RxNetConfigBuilder
开启系统日志
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited