semantic_zoom library

Pinch to change how much text a list shows, not how big it is.

For a single tap-to-expand text, use ExpandableLeveledText. For a pinchable list, start with SemanticZoomController, SemanticZoomListView and LeveledTextView. Build content with LeveledText.parse or LeveledText.fromVersions; LeveledPrompt helps an LLM write versions that morph smoothly.

Classes

DefaultSemanticZoomController
Creates, provides and disposes a SemanticZoomController, so you don't need a StatefulWidget, a vsync or dispose() of your own. Like DefaultTabController.
ExpandableLeveledText
A single piece of leveled text that expands in place on tap, with no list or controller to set up: an animated "read more".
ExpandableLeveledTextState
State of an ExpandableLeveledText; reach it with a GlobalKey to change the level from outside.
LazyLeveledTextView
Like LeveledTextView, but for text from a LeveledTextLoader: the brief text shows at once, and the longer versions are loaded the first time this entry starts to zoom (a pinch, a level change, itemId expanding, or a screen reader's increase action).
LeveledPrompt
Helpers for asking an LLM to write versions of a text that morph smoothly with LeveledText.fromVersions.
LeveledText
Text that exists at several detail levels, stored as a single token stream.
LeveledTextLayout
Measures LeveledText with Flutter's own paragraph engine.
LeveledTextLoader
Leveled text whose longer versions are fetched only when needed: the brief text is available at once, and the rest is loaded (for example from an API or an LLM) the first time someone expands it.
LeveledTextView
Shows text at the controller's current zoom, morphing between levels.
LeveledToken
A word (or glued punctuation) tagged with the range of detail levels at which it is visible, plus optional styling and a link.
LeveledTransition
The change from one level to the next.
LeveledVersionsReport
How smoothly a set of versions will morph. See LeveledText.checkVersions.
LevelLayout
Where every token sits at one detail level.
RenderSliverSemanticZoomList
Render object for SliverSemanticZoomList.
SemanticZoomAnchorClient
Something that can hold its content still while the zoom changes, e.g. RenderSliverSemanticZoomList.
SemanticZoomController
Drives a semantic zoom: a continuous zoom value (e.g. 0.0 → 2.0), the discrete level it last settled on, and optional per-item levels.
SemanticZoomDetector
Turns pinch gestures into semantic-zoom changes on controller.
SemanticZoomGridView
A ready-made scrolling grid with semantic zoom: a SemanticZoomDetector around a CustomScrollView holding a SliverSemanticZoomGrid.
SemanticZoomListView
A ready-made scrolling list with semantic zoom: a SemanticZoomDetector around a CustomScrollView holding a SliverSemanticZoomList.
SemanticZoomScope
Makes a SemanticZoomController available to descendants such as LeveledTextView. SemanticZoomDetector inserts one automatically.
SliverSemanticZoomGrid
A grid for semantic zoom: items in rows, where each row is as tall as its tallest item and grows as they zoom.
SliverSemanticZoomList
A SliverList that keeps a pinned item still while items around it grow or shrink during a semantic zoom.

Typedefs

ExpandableFooterBuilder = Widget Function(BuildContext context, int level, int maxLevel, VoidCallback toggle)
Builds a footer under an ExpandableLeveledText, e.g. a "Show more" button. toggle steps to the next level (wrapping if enabled).
LazyErrorBuilder = Widget Function(BuildContext context, Object error, VoidCallback retry)
Builds what is shown under a LazyLeveledTextView when loading failed. Call retry to try again.
LazyLoadingBuilder = Widget Function(BuildContext context)
Builds what is shown under a LazyLeveledTextView while it loads.
SemanticZoomWidgetBuilder = Widget Function(BuildContext context, bool isPinching)
Builds the scrollable child. isPinching is true while a pinch is active; disable scrolling then, e.g. with NeverScrollableScrollPhysics.