rebuild<N extends RebuildableNotifier<T, R> , T, R> method
R
rebuild<N extends RebuildableNotifier<T, R> , T, R>(
- RebuildableProvider<
N, T, R> provider, [ - LabeledReference? debugOrigin
override
Rebuilds a rebuildable provider (e.g. ViewProvider, FutureProvider) and returns the result of the builder function.
Remember: Rebuildable providers allow you to watch other providers within the builder function.
This is NOT the same as calling Ref.dispose and then Ref.read. In this case the notifier is disposed and listeners won't be notified.
Implementation
@override
R rebuild<N extends RebuildableNotifier<T, R>, T, R>(
RebuildableProvider<N, T, R> provider, [
LabeledReference? debugOrigin,
]) {
if (provider is FamilySelectedWatchable) {
// Special case for family providers
// Here, we rebuild the child provider referenced by the parameter.
final familyWatchable = provider as FamilySelectedWatchable;
final notifier = _getState(familyWatchable.provider);
final param = familyWatchable.param;
if (!notifier.isParamInitialized(param)) {
notifier.initParam(param);
}
final cProvider = notifier.getProviderMap()[param]!;
final cNotifier = _getState(cProvider) as RebuildableNotifier<Object?, R>;
return cNotifier.rebuildImmediately(debugOrigin ?? this);
}
final notifier = _getState(provider as BaseProvider<N, T>);
return notifier.rebuildImmediately(debugOrigin ?? this);
}