WorkFuture<D, T extends WorkData<D>> class

任务执行专用Future,提供了取消功能

D为关联的接口结果数据类型,T为接口响应包装类型WorkData

Implemented types
Available Extensions

Properties

hashCode int
The hash code for this object.
no setterinherited
onCanceled → void Function()
用户执行取消事件
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

asStream() Stream<T>
Creates a Stream containing the result of this future.
override
cancel() → void
取消正在进行的任务
catchError(Function onError, {bool test(Object error)?}) Future<T>
Handles errors emitted by this Future.
override
message() Future<String?>
返回WorkData.message无论任务成功或失败
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
requiredResultOrThrow([FutureOr<void> onDo(D value)?]) Future<D>
获取非空结果或抛出异常
requiredResultOrThrowMessage([FutureOr<void> onDo(D value)?]) Future<D>
获取非空结果或抛出纯字符串异常
result() Future<D?>
返回任务执行结果WorkData.result,无论任务成功或失败
resultOrThrow([FutureOr<void> onDo(D? value)?]) Future<D?>
获取结果或抛出异常
resultOrThrowMessage([FutureOr<void> onDo(D? value)?]) Future<D?>
获取结果或抛出纯字符串异常
success() Future<bool>
返回任务执行结果的未来
then<R>(FutureOr<R> onValue(T value), {Function? onError}) Future<R>
Register callbacks to be called when this future completes.
override
thenFailed<R>(FutureOr<R?> onValue(T value)) Future<R?>
仅当Work失败时,即WorkData.success为false时才执行onValue
thenResult<R>(FutureOr<R?> onValue(D? value)) Future<R?>
Work.start().then((data) => data.result)的快捷方式 它会等待Work.start完成后执行onValue参数为WorkData.result
thenSuccessful<R>(FutureOr<R?> onValue(T value)) Future<R?>
仅当Work成功时,即WorkData.success为true时才执行onValue
timeout(Duration timeLimit, {FutureOr<T> onTimeout()?}) Future<T>
Stop waiting for this future after timeLimit has passed.
override
toString() String
A string representation of this object.
override
whenComplete(FutureOr<void> action()) Future<T>
Registers a function to be called when this future completes.
override

Operators

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