ProviderDisposedException class final
Thrown when a FutureProvider or StreamProvider is disposed before it has emitted its first value.
This is a normal lifecycle event — it occurs when an autoDispose provider
is no longer listened to (e.g. due to navigation) while it is still loading.
It is not a programming error.
ProviderObserver.providerDidFail will not be called for this exception.
If a downstream provider awaits a disposed provider's FutureProvider.future, it will receive this exception. You can catch it to treat disposal as a no-op rather than an error:
final dependentProvider = FutureProvider.autoDispose<String>((ref) async {
try {
final value = await ref.watch(myProvider.future);
return 'Got $value';
} on ProviderDisposedException {
// Upstream disposed before completing — this is expected.
return '';
}
});
- Implemented types
- Annotations
-
- @publicInMisc
Constructors
-
ProviderDisposedException(ProviderBase<
Object?> provider) -
Creates a ProviderDisposedException for
provider.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
provider
→ ProviderBase<
Object?> -
The provider that was disposed before emitting a value.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited