getOrNull<T> method
Retrieves the value of the requested type T
or returns null
when it can't be provided.
If watch
is not set, implementation should perform an educated guess (e.g. based on whether it's called during
a build).
Exact meaning of "watching" depends on the implementation and may not be supported.
Implementation
T? getOrNull<T>({bool? watch}) {
final value = getUnsafe(T, watch: watch);
if(value == ProviderContext.valueNotFound) return null;
return value as T;
}