Flutter ValueNotifier notifyListeners twice

114 Views Asked by At

I use ValueNotifier in Flutter and use setValue when data changed.

ValueNotifier<GameResultMessage?> gameResultMessage = ValueNotifier(null);
//
gameResultMessage.value = gameResultMessage;

setValue source code

  set value(T newValue) {
    if (_value == newValue) {
      return;
    }
    _value = newValue;
    notifyListeners();
  }

I want to notify observer everytime whatever data is new or old. (Run some animation)

But when I call notifyListeners() animation will run twice. If I don't call notifyListeners(), animation won't run when data not changed.

How to solve it?

0

There are 0 best solutions below