whenOrNull<U> method
U?
whenOrNull<U>({
- U initial(
- T?
- U waiting(
- T?
- U complete(
- T
- U error(
- T?,
- Object,
- StackTrace
A method that returns a value returned from one of callback functions corresponding to the current phase of an asynchronous operation.
This is identical to when except that all properties are
optional. It returns null
if the callback corresponding to
the current phase has not been provided,
Implementation
U? whenOrNull<U>({
U Function(T?)? initial,
U Function(T?)? waiting,
U Function(T)? complete,
U Function(T?, Object, StackTrace)? error,
}) {
return when(
initial: initial,
waiting: (data) => waiting?.call(data),
complete: (data) => complete?.call(data),
error: (data, e, s) => error?.call(data, e, s),
);
}