/scroll-spy:migrate-scroll-spy-v0-to-v1from ScrollSpy Assistant
Upgrades Flutter projects from scroll_spy 0.1.x/0.2.x to 1.x. Fixes build errors from removed APIs like ScrollSpyRegistry, ScrollSpyGeometry, and commitFrame.
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.
Read when SKILL.md points to them.
1.0.0 rebuilt the engine internals for performance. The app-facing API is unchanged; only code that touched engine internals or fed the controller by hand needs work. Source versions supported here: 0.1.x and 0.2.x (0.1 to 0.2 was additive, so both migrate in one hop). Target: any 1.x.
Read the project's pubspec.yaml (scroll_spy: constraint) and pubspec.lock
(resolved version). Then search for the only symbols that break:
grep -rnE "commitFrame|ScrollSpyDiff|ScrollSpyRegistry|ScrollSpyGeometry|ScrollSpySelection|scroll_spy/src/" lib test
^1.x and the grep is empty: the project is migrated;
report that and stop.Confirm a clean VCS state and a passing flutter test baseline first, so
migration failures are attributable. 1.x requires Dart SDK ^3.6.0 and
Flutter >=3.27.0; check the project's environment: allows that.
In pubspec.yaml set scroll_spy: ^1.0.0, run flutter pub get.
Everything in the public app surface is unchanged: scope, items (ScrollSpyItem,
ScrollSpyItemLite), all wrappers, all builders/listeners, regions, anchors,
policies, stability, update policies, viewportInsets, notification filters,
debug overlay, diagnostics, and every ScrollSpyController read API
(primaryId, focusedIds, snapshot, itemFocusOf, itemIsPrimaryOf,
itemIsFocusedOf, itemIsVisibleOf, tryGetItemFocus). Files that only use
these need zero changes; do not churn them.
Removed in 1.0.0, with replacements:
| Removed | Was used for | Replacement |
|---|---|---|
ScrollSpyController.commitFrame(snapshot) | feeding hand-built snapshots into a controller | see decision list below |
ScrollSpyDiff.commitToController(...) | same, via the engine seam | same decision list |
ScrollSpyRegistry, ScrollSpyRegistryEntry | inspecting registered items | controller.snapshot.value.items (all measurable items) or tryGetItemFocus(id) |
ScrollSpyGeometry, ScrollSpyGeometryResult | manual geometry math | no public equivalent; app code should consume per-item metrics (visibleFraction, distanceToAnchorPx, rects in debug) instead |
ScrollSpySelection, ScrollSpySelectionResult | manual primary ranking | express the ranking as ScrollSpyPolicy.custom(compare: ...) |
imports of package:scroll_spy/src/... | reaching internals | import package:scroll_spy/scroll_spy.dart only |
Choosing a commitFrame replacement:
.value getters,
never needs a second frame): construct the controller with
ScrollSpyController(initialSnapshot: ScrollSpySnapshot(...)). The seed
serves all reads until a real scope commits. This is the smallest change
and keeps the test widget-free.pump()s) and the scroll patterns per update policy.ValueListenables and
back them with plain ValueNotifiers the replayer owns; (b) keep the
tool pinned to 0.2.7. Do not fake a controller subclass; its commit path
is @internal. This choice affects call sites, so surface it to the user
before rewriting.ScrollSpyStability.minPrimaryDuration now uses a monotonic clock. Tests
that manipulated wall-clock time to expire hold windows must use pumped
test time instead.ScrollSpySnapshot.computedAt is stamped when the snapshot instance is
materialized (lazily), not when the engine computed. Do not assert exact
timestamps or cross-snapshot time deltas.ScrollSpyScope(debug: true);
tests inspecting the debug overlay or engine debug stream must set it.dart format <changed files>
flutter analyze
flutter test
grep -rnE "commitFrame|ScrollSpyDiff|ScrollSpyRegistry|ScrollSpyGeometry|ScrollSpySelection|scroll_spy/src/" lib test
The grep must come back empty. Expect no new analyzer warnings from this
migration; if flutter analyze reports deprecations, they are unrelated.
Report any Step 4 case-3 decisions you made and every file you changed.
Restore pubspec.yaml (and pubspec.lock if committed) to the previous
constraint and run flutter pub get; 0.2.7 remains published.
Before (0.2.x):
final controller = ScrollSpyController<int>();
controller.commitFrame(snapshotWithPrimary(1));
expect(controller.primaryId.value, 1);
After (1.x, seeding path):
final controller = ScrollSpyController<int>(
initialSnapshot: snapshotWithPrimary(1),
);
expect(controller.primaryId.value, 1);
After (1.x, behavior path): see the full harness in references/test-harness.md.
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./diagnose-scroll-spyUse when scroll_spy misbehaves in a Flutter app and the cause is unknown: primaryId stays null, focusedIds stays empty, listeners or builders never fire, focus ignores jumpTo or programmatic scrolls, the highlighted item is offset under a pinned header or app bar, state resets on setState, nested scrollables interfere, or a widget test reads null focus state./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-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