/scroll-spy:diagnose-scroll-spyfrom ScrollSpy Assistant
Diagnoses scroll_spy misbehavior in Flutter apps: null/empty focus, offset highlights under pinned headers, stale state, nested scrollable interference, and widget test failures.
Ships in ScrollSpy Assistant. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Work symptom-first: find the row that matches, verify its cause in the code, apply the smallest fix, then confirm with the overlay workflow at the end. Most reports match exactly one row.
| Symptom | Cause to verify | Fix |
|---|---|---|
| Everything null/empty, never any state | No ScrollSpyItem/ScrollSpyItemLite in the subtree, or scope not above the scrollable | Wrap items; scope must enclose the scrollable that scrolls them |
| Same, but items exist | Type parameter mismatch: ScrollSpyScope<String> with ScrollSpyItem<int> (or an omitted <T> defaulting to dynamic). Items look up the scope by exact T; a mismatch throws an assert in debug builds but silently tracks nothing in release | Make every scope, item, controller, builder, and listener share the same concrete T |
| Same, only in widget tests | State is committed in post-frame callbacks: registration on frame 1, compute on frame 2 | After pumpWidget, pump() twice before asserting |
| First frame after mount shows no focus (runtime) | Same post-frame pipeline; initial state lands one frame late by design | Do not read focus in initState; listen, or read after the first frames |
Focus ignores jumpTo/programmatic scrolls until the user wiggles | Scope observes notifications only; a bare jumpTo on an external ScrollController can bypass them | Pass the same controller as scrollController: to the scope or wrapper (wrappers wire it to both the view and the scope) |
Highlight/primary is offset under a pinned SliverAppBar, tab bar, safe area, or bottom bar | Region anchored in the full viewport while an overlay covers part of it | viewportInsets: EdgeInsets.only(top: <overlay px>) (or bottom:); keep insetsAffectVisibility: true so covered items also stop counting as visible |
Highlight resets to null on setState; external listeners go dead | ScrollSpyController created inside build, so each rebuild swaps in a fresh controller and orphans the old one | Make it a State field; dispose() it; never construct it in build |
| Focus updates when an inner carousel scrolls, or not at all in nested scrollables | Notification depth/filtering: default notificationDepth: 0 targets the immediate child scrollable; nested setups deliver other depths | Set notificationDepth, or notificationPredicate/metricsNotificationPredicate (filter on n.metrics.axis) |
| Primary stale while scrolling, corrects after stop | onScrollEnd/hybrid update policy semantics, not a bug | If per-scroll updates are wanted, use perFrame (default); see the tune-scroll-spy-stability skill |
| Primary flickers, sticks, or picks the "wrong" item near boundaries | Selection/stability configuration | Use the tune-scroll-spy-stability skill |
| First/last items never become primary with a centered anchor | Edge geometry: at the list edges those items cannot reach the anchor | Add symmetric list padding of (viewportExtent - itemExtent) / 2, bias the anchor, or accept the nearest-fallback behavior |
| Items inside a horizontal pager/second scrollable never focus in the outer scope | Items resolve to their nearest enclosing viewport; the scope tracks the first-registered viewport and skips items from others | Give the inner scrollable its own scope of its own type, or restructure which widget registers |
Off-screen kept-alive items (AutomaticKeepAlive) report nothing | Unlaidout children are unmeasurable that pass by design | Treat absence as "not visible"; do not special-case |
| Debug assert about fast-path geometry mismatch with a custom sliver | A custom sliver's paint transform lies about actual positions | Fix the sliver's applyPaintTransform, or file an issue with the assert text |
itemRectInViewport/visibleRectInViewport always null | Rects are only populated with debug: true + ScrollSpyDebugConfig(includeItemRectsInFrame: true) | Enable both while debugging; keep off in release |
| Listener attached but no callback for existing state | Listenables fire on transitions; attaching produces no initial call | Read .value for current state; use listeners for changes |
When no row matches, or to confirm one:
debug: true on the scope/wrapper (optionally
debugConfig: ScrollSpyDebugConfig(showLabels: true)). Red = focus
region, green = primary outline, yellow = focused outlines, blue =
visible bounds.
ScrollSpyDiagnostics.sink = ScrollSpyDiagnostics.debugPrintSink();
(set to null when done).controller.snapshot.value shows primaryId, focusedIds,
visibleIds, and per-item metrics for everything measurable this pass.State the confirmed root cause, the one-line fix, and what you verified (overlay observation, passing test, or both). If the behavior needed a config change with product implications (anchor moves, insets, update policy), say what tradeoff was made.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub omar-hanafy/scroll_spy --plugin scroll-spy7 skills in this plugin
/convert-visibility-detector-to-scroll-spyUse when replacing the visibility_detector package with scroll_spy in a Flutter app, when migrating VisibilityDetector, VisibilityInfo, or VisibilityDetectorController code, or when a VisibilityDetector-based feed additionally needs a single stable primary item, per-item focus metrics, or scroll-performance improvements./integrate-scroll-spyUse when adding the scroll_spy Flutter package to a screen or feature: autoplay video feeds, current-item tracking, reading-position or TOC highlighting, impression analytics, carousels or PageViews, photo grids, prefetching around the focused item, or wiring ScrollSpyScope, ScrollSpyItem, and ScrollSpyController for the first time, including widget tests for that integration. Not for scrolling work unrelated to focus or visibility tracking (saving/restoring scroll offsets, scroll physics, scroll-to-index)./migrate-scroll-spy-v0-to-v1Use when upgrading a Flutter project from scroll_spy 0.1.x or 0.2.x to 1.x, when a build breaks after a scroll_spy upgrade with unresolved names such as ScrollSpyRegistry, ScrollSpyGeometry, ScrollSpySelection, ScrollSpyDiff, or commitFrame, or when estimating how much work the 0.x to 1.x upgrade needs./migrate-scroll-spy-v1-to-v2Upgrade an existing scroll_spy 1.x integration to 2.x, including SDK constraints and optional ScrollCacheExtent migration. Use for 1.x-to-2.x upgrades or SDK resolution failures after that upgrade./optimize-scroll-spy-performanceUse when a Flutter screen whose code uses scroll_spy (ScrollSpyScope, ScrollSpyItem, ScrollSpyController) shows jank, dropped frames, high CPU, or rebuild storms, or when choosing between ScrollSpyItem, ScrollSpyItemLite, focus builders, listeners, and snapshot listening in large scroll_spy feeds. Not for general Flutter list or image scrolling performance where scroll_spy is not involved./tune-scroll-spy-stabilityUse when scroll_spy selects the right things but behaves badly over time: the primary item flickers or alternates between two items, switches too eagerly or too sluggishly, stutters at card boundaries in autoplay, goes null between items or during fast scrolls, sticks to an old item too long, or updates at the wrong moments (mid-drag versus after settling).Other plugins' skills for the same job