notifyIndexChanged method

void notifyIndexChanged(
  1. int widgetIndex
)

Notifies all listeners that the current heading index has changed.

This is called by the MarkdownWidget when scrolling causes a new heading to become visible.

The widgetIndex is the index in the MarkdownGenerator's widget tree of the newly visible heading.

Implementation

void notifyIndexChanged(int widgetIndex) {
  if (_isDisposed) return;

  for (final listener in _indexChangeListeners) {
    try {
      listener.call(widgetIndex);
    } catch (e) {
      // Ignore errors in listeners to prevent one bad listener from breaking others
      debugPrint('Error in TocIndexCallback: $e');
    }
  }
}