TocScrollSpy class

A client-side component that highlights the active TOC link based on scroll.

Uses Jaspr's @client annotation for client-side hydration. On the client, sets up an IntersectionObserver to watch heading elements and toggles the active class on corresponding .toc-link elements.

Renders nothing on the server — the visual TOC is rendered by TableOfContents. Place this component alongside TableOfContents:

Row(children: [
  Expanded(child: div(classes: 'docs-content', [RawText(html)])),
  TableOfContents(entries: toc),
  TocScrollSpy(),
])
Inheritance
Available extensions
Annotations

Constructors

TocScrollSpy({Key? key})
const

Properties

hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one component replaces another component in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

apply({String? id, String? classes, Styles? styles, Map<String, String>? attributes, Map<String, EventCallback>? events}) Component

Available on Component, provided by the ComponentApplyExtension extension

createElement() Element
Creates a StatefulElement to manage this component's location in the tree.
inherited
createState() State<TocScrollSpy>
Creates the mutable state for this component at a given location in the tree.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited