FutureHookOptions class
所有的 Options 均是可选的。
Constructors
- FutureHookOptions({bool manual = false, dynamic initialData, dynamic onSuccess(dynamic data, dynamic params)?, dynamic onError(dynamic error, dynamic params)?, String? cacheKey, dynamic defaultParams, int loadingDelay = 0, int pollingInterval = 0})
- 构建
Properties
- cacheKey ↔ String?
-
请求唯一标识。如果设置了 cacheKey,我们会启用缓存机制
我们会缓存每次请求的 data , error , params , loading
在缓存机制下,同样的请求我们会先返回缓存中的数据,同时会在背后发送新的请求,待新数据返回后,重新触发数据更新
getter/setter pair
- defaultParams ↔ dynamic
-
如果 manual=false ,自动执行 run 的时候,默认带上的参数
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialData ↔ dynamic
-
默认的 data
getter/setter pair
- loadingDelay ↔ int
-
设置显示 loading 的延迟时间,避免闪烁
getter/setter pair
- manual ↔ bool
-
默认 false。 即在初始化时自动执行 service。
如果设置为 true,则需要手动调用 run 触发执行。
getter/setter pair
- onError ↔ (dynamic Function(dynamic error, dynamic params)?)
-
future 报错 时触发,参数为 data 和 params
getter/setter pair
- onSuccess ↔ (dynamic Function(dynamic data, dynamic params)?)
-
在 manual = false 时,refreshDeps 变化,会触发 service 重新执行
List
getter/setter pair
- pollingInterval ↔ int
-
轮询间隔,单位为毫秒。设置后,将进入轮询模式,定时触发 run
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
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