pauseNotifications<T> method

T pauseNotifications<T>(
  1. ChangeHandler<T> handler,
  2. [bool notifyAfter = false]
)

Pause notifications until after a synchronous handler has completed. If notifyAfter is true, then listeners will automatically be notified after the callback completes. Otherwise, you must notify the listeners;

Implementation

T pauseNotifications<T>(ChangeHandler<T> handler,
    [bool notifyAfter = false]) {
  final prevState = _paused;
  _paused = true;
  final result = handler();
  _paused = prevState;

  if (notifyAfter) {
    notifyListeners();
  }

  return result;
}