hasListeners property

bool hasListeners

Return true if there are listeners.

If there is no listeners, the app can save on creating the event object.

Only call this when kFlutterMemoryAllocationsEnabled is true.

Implementation

bool get hasListeners {
  if (!kFlutterMemoryAllocationsEnabled) {
    return false;
  }
  if (_listenersContainNulls) {
    return _listeners?.firstWhere((ObjectEventListener? l) => l != null) != null;
  }
  return _listeners?.isNotEmpty ?? false;
}