match<R> method
R?
match<R>({
- R fulfilled(
- T
- R rejected(
- dynamic
- R pending()?,
Maps the current state of this.
Returns null if a handler for the current state is not provided.
Implementation
R? match<R>(
{R Function(T)? fulfilled,
// ignore:avoid_annotating_with_dynamic
R Function(dynamic)? rejected,
R Function()? pending}) {
final status = this.status;
if (status == FutureStatus.fulfilled) {
return fulfilled == null ? null : fulfilled(result as T);
} else if (status == FutureStatus.rejected) {
return rejected == null ? null : rejected(result);
}
return pending == null ? null : pending();
}