value property

  1. @override
T? value
override

The value currently exposed.

It will return the previous value during loading/error state. If there is no previous value, reading value during loading state will return null. While during error state, the error will be rethrown instead.

If you do not want to return previous value during loading/error states, consider using unwrapPrevious with valueOrNull:

ref.watch(provider).unwrapPrevious().valueOrNull;

This will return null during loading/error states.

Implementation

@override
T? get value {
  if (!hasValue) {
    throwErrorWithCombinedStackTrace(error, stackTrace);
  }
  return _value;
}