PreloadTask<T> class

预加载任务 — 通用任务模型

支持两种任务类型:

  • provider 非空时为 Provider 任务(由 Riverpod 提供执行)
  • method 非空时为普通方法任务(直接执行异步函数)

依赖统一通过 dependencies 字符串 ID 声明,可跨类型依赖。

Constructors

PreloadTask({ProviderListenable<T>? provider, Future<void> method()?, String? id, List<String> dependencies = const [], Future<bool> checkBeforeExecute()?, Duration checkRetryDelay = const Duration(milliseconds: 300), int maxCheckRetries = 10, TaskConfig? config})
const

Properties

checkBeforeExecute → Future<bool> Function()?
执行前检查函数 返回 true 表示可以执行,返回 false 则等待后重试
final
checkRetryDelay → Duration
检查失败后的重试间隔
final
config → TaskConfig
任务配置
final
dependencies → List<String>
依赖的其他任务 ID(字符串,支持跨类型依赖) 可引用 Provider 任务的 ID 或方法任务的 ID
final
hasCheck → bool
是否有执行前检查
no setter
hashCode → int
The hash code for this object.
no setteroverride
id → String
任务 ID
no setter
isMethodTask → bool
是否为普通方法任务
no setter
isProviderTask → bool
是否为 Provider 任务
no setter
isRequired → bool
是否为必需任务
no setter
maxCheckRetries → int
最大检查重试次数
final
method → Future<void> Function()?
普通异步方法(方法任务时非空)
final
name → String
任务名称(用于显示)
no setter
priority → int
优先级
no setter
provider → ProviderListenable<T>?
Provider 实例(Provider 任务时非空)
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
timeout → Duration?
超时时长
no setter

Methods

copyWith<T>({ProviderListenable<T>? provider, Future<void> method()?, String? id, List<String>? dependencies, Future<bool> checkBeforeExecute()?, Duration? checkRetryDelay, int? maxCheckRetries, TaskConfig? config}) → PreloadTask<T>
创建副本
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

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