whenStateChanged method
Called when the notifier's state changes.
Implement this to determine when to trigger a rebuild based on state changes.
previous is the previous state, current is the new state, and reBuild is a callback to trigger a rebuild.
Implementation
@override
void whenStateChanged(S previous, S current, VoidCallback reBuild) {
if (buildWhen?.call(previous, current) ?? true) reBuild();
}