requireValue property
T
get
requireValue
Returns the value if the state is AsyncData, otherwise throws a StateError.
Implementation
T get requireValue {
final self = this;
if (self is AsyncData<T>) return self.value;
if (self is AsyncLoading<T> && self.previous != null) {
return self.previous!.value;
}
if (self is AsyncError<T> && self.previous != null) {
return self.previous!.value;
}
if (self is AsyncError<T>) {
throw StateError('AsyncValue has error: ' + self.error.toString());
}
throw StateError('AsyncValue is in Loading state');
}