createWhenListener function
create the listener for provider.when filter
Implementation
void createWhenListener(Target target) {
final notifier = target.notifier as StateNotifier;
target.selectValue = target.callback(notifier.state, notifier.state);
// ignore: prefer_function_declarations_over_variables
final listener = (newState) {
// rebuild the Consumer using the boolean returned by the callback
final allowRebuild = target.callback(notifier.oldState, newState);
target.selectValue = allowRebuild;
if (allowRebuild) {
if (target.rebuild != null) {
target.rebuild!();
}
}
};
target.listener = listener;
}