我有两个提供者,一个在听另一个:
final counterStepProvider = Provider<AsyncValue<int>>(
(ref) => ref.watch(counterProvider.state).whenData((double value) => value.floor()));
final counterProvider = StateNotifierProvider<CounterState>((ref) => CounterState());
class CounterState extends StateNotifier<AsyncValue<double>> {
CounterState(this.minCounter, this.maxCounter) : super(AsyncLoading()) {
state = AsyncData(0);
}
set counter(double counter) {
state = AsyncData(counter);
}
}
问题在于,即使状态具有相同的值,counterStepProvider
也会始终更新其侦听器。有没有办法只在 value.floor != state
时更新?