requireData property Null safety
Returns latest data received, failing if there is no data.
Throws error, if hasError. Throws StateError, if neither hasData nor hasError.
Implementation
T get requireData {
if (hasData) {
return data!;
}
if (hasError) {
Error.throwWithStackTrace(error!, stackTrace!);
}
throw StateError('Snapshot has neither data nor error');
}