sendNotification<T> static method

void sendNotification<T>(
  1. dynamic target,
  2. T? object
)

发送通知

Implementation

static void sendNotification<T>(dynamic target, T? object) {
  final notifier = _notifiers[target];
  if (notifier == null) return;

  // ValueNotifier 对相同值不会重复通知,事件总线需要保持每次发送都可见
  if (notifier.value == object) {
    for (var listener in _listeners[target]?.toList() ?? const []) {
      listener(object);
    }
    return;
  }

  (notifier as ValueNotifier<T?>).value = object;
}