SmartRequest<T> class

请求 DTO

Constructors

SmartRequest({required String path, HttpMethod? method, dynamic data, Map<String, dynamic>? queryParameters, Map<String, String>? headers, Duration? timeout, CancelToken? cancelToken, bool isFormData = false, JsonDecoder<T>? fromJson, BytesDecoder<T>? fromBytes, RawResponseDecoder<T>? fromResponse, List<SmartPlugin>? extraPlugins, Set<Type>? excludePlugins, Map<Type, Set<LifecycleHook>>? skipHooks, Set<String>? consumedErrorCodes, BaseOptions? optionsOverride, CacheOptions? cacheOptions, OnStart? onStart, OnSuccess<T>? onSuccess, OnError? onError, OnFinish<T>? onFinish, ErrorMessageBuilder? errorMessageBuilder, String? successMessage, SuccessMessageBuilder<T>? successMessageBuilder})
const
SmartRequest.get(String path, {Map<String, dynamic>? queryParameters, Map<String, String>? headers, Duration? timeout, CancelToken? cancelToken, JsonDecoder<T>? fromJson, BytesDecoder<T>? fromBytes, RawResponseDecoder<T>? fromResponse, List<SmartPlugin>? extraPlugins, Set<Type>? excludePlugins, Map<Type, Set<LifecycleHook>>? skipHooks, Set<String>? consumedErrorCodes, BaseOptions? optionsOverride, CacheOptions? cacheOptions, OnStart? onStart, OnSuccess<T>? onSuccess, OnError? onError, OnFinish<T>? onFinish, ErrorMessageBuilder? errorMessageBuilder, String? successMessage, SuccessMessageBuilder<T>? successMessageBuilder})
创建 GET 请求
factory
SmartRequest.post(String path, {dynamic data, Map<String, dynamic>? queryParameters, Map<String, String>? headers, Duration? timeout, CancelToken? cancelToken, bool isFormData = false, JsonDecoder<T>? fromJson, BytesDecoder<T>? fromBytes, RawResponseDecoder<T>? fromResponse, List<SmartPlugin>? extraPlugins, Set<Type>? excludePlugins, Map<Type, Set<LifecycleHook>>? skipHooks, Set<String>? consumedErrorCodes, BaseOptions? optionsOverride, CacheOptions? cacheOptions, OnStart? onStart, OnSuccess<T>? onSuccess, OnError? onError, OnFinish<T>? onFinish, ErrorMessageBuilder? errorMessageBuilder, String? successMessage, SuccessMessageBuilder<T>? successMessageBuilder})
创建 POST 请求
factory

Properties

cacheOptions → CacheOptions?
单次请求缓存选项
final
cancelToken → CancelToken?
取消令牌
final
consumedErrorCodes → Set<String>?
已消费的错误码列表
final
data → dynamic
请求数据(POST/PUT 的 body)
final
errorMessageBuilder → ErrorMessageBuilder?
错误消息构建器
final
excludePlugins → Set<Type>?
排除插件(热拔)- 仅对当前请求生效
final
extraPlugins → List<SmartPlugin>?
额外插件(热插)- 仅对当前请求生效
final
fromBytes → BytesDecoder<T>?
字节流解析器(用于 Protobuf 等二进制协议)
final
fromJson → JsonDecoder<T>?
JSON 解析器(用于解析预处理后的 data 或原始 JSON)
final
fromResponse → RawResponseDecoder<T>?
原始响应解析器(完全自定义解析逻辑)
final
hashCode → int
The hash code for this object.
no setterinherited
headers → Map<String, String>?
请求头
final
isFormData → bool
是否是 FormData
final
method → HttpMethod?
请求方法
final
onError → OnError?
请求错误回调
final
onFinish → OnFinish<T>?
请求结束回调(无论成功失败)
final
onStart → OnStart?
请求开始回调
final
onSuccess → OnSuccess<T>?
请求成功回调
final
optionsOverride → BaseOptions?
请求选项覆盖
final
path → String
请求路径
final
queryParameters → Map<String, dynamic>?
查询参数
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
skipHooks → Map<Type, Set<LifecycleHook>>?
跳过特定插件的特定生命周期钩子
final
successMessage → String?
静态成功消息
final
successMessageBuilder → SuccessMessageBuilder<T>?
成功消息构建器
final
timeout → Duration?
超时时间(覆盖全局配置)
final

Methods

copyWith({String? path, HttpMethod? method, dynamic data, Map<String, dynamic>? queryParameters, Map<String, String>? headers, Duration? timeout, CancelToken? cancelToken, bool? isFormData, JsonDecoder<T>? fromJson, BytesDecoder<T>? fromBytes, RawResponseDecoder<T>? fromResponse, List<SmartPlugin>? extraPlugins, Set<Type>? excludePlugins, Map<Type, Set<LifecycleHook>>? skipHooks, Set<String>? consumedErrorCodes, BaseOptions? optionsOverride, CacheOptions? cacheOptions, OnStart? onStart, OnSuccess<T>? onSuccess, OnError? onError, OnFinish<T>? onFinish, ErrorMessageBuilder? errorMessageBuilder, String? successMessage, SuccessMessageBuilder<T>? successMessageBuilder}) → SmartRequest<T>
复制并修改请求
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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