select<N extends StateNotifier<S> , S, R> method
read a Notifier from one provider and subscribe the widget to the changes of this Notifier.
target
is a value gotten from .select or .when
the widget only will be rebuilded depending of the condition of each method.
Implementation
@override
R select<N extends StateNotifier<S>, S, R>(
SelectFilteredProvider<N, S, R> filter,
) {
// if the widget was rebuilded
if (_isExternalBuild) {
_clearDependencies();
}
_isExternalBuild = false;
final notifier = filter.notifier;
final insideDependencies = _builders.containsKey(notifier);
// if there is not a listener for the current provider
if (!insideDependencies) {
filter.reaction = (_) => _rebuild();
filter.createListener();
// add the listener to the current notifier
_builders[notifier] = filter.listener;
_targets[notifier] = filter;
notifier.addListener(filter.listener);
}
return (_targets[notifier] as SelectFilteredProvider)
.selectValue; // coverage:ignore-line
}