Skip to content

Conversation

@rkishan516
Copy link
Contributor

@rkishan516 rkishan516 commented Aug 27, 2025

FindChildIndexCallback to take seperators into account for seperated named constructor in ListView and SliverList
fixes: #174261

Migration guide

flutter/website#12636

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels Aug 27, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes an issue where findChildIndexCallback did not account for separators in ListView.separated and SliverList.separated. The change correctly wraps the callback to multiply the returned index by two. The accompanying tests verify that state is preserved correctly with this change. My review focuses on improving maintainability by reducing code duplication in both the implementation and the new tests. I've suggested extracting the duplicated logic into helper functions.

Comment on lines 1481 to 1486
findChildIndexCallback: findChildIndexCallback == null
? null
: (Key key) {
final int? itemIndex = findChildIndexCallback(key);
return itemIndex == null ? null : itemIndex * 2;
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This logic for wrapping findChildIndexCallback is also present in SliverList.separated. To improve maintainability and avoid code duplication, consider extracting this logic into a shared helper function that can be used in both places.

@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Copy link
Contributor

@victorsanni victorsanni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While our tests pass, this is probably going to break anyone currently using ListView.separated.findChildIndexCallback because they are probably multiplying that result by 2 already to workaround this.

I think we should deprecate this property but only on the separated constructor. And replace with a ListView.separated.findItemIndexCallback. Is this possible? What do you think @rkishan516?

@rkishan516
Copy link
Contributor Author

I think we should deprecate this property but only on the separated constructor. And replace with a ListView.separated.findItemIndexCallback. Is this possible? What do you think @rkishan516?

Yes, it is possible. I was just worried about seperated constructor being inconsistent with others.

@rkishan516 rkishan516 force-pushed the seperated-builder-index-callback branch from e3b0250 to 55dd1f6 Compare October 16, 2025 02:10
@github-actions github-actions bot added the c: tech-debt Technical debt, code quality, testing, etc. label Oct 16, 2025
@rkishan516 rkishan516 force-pushed the seperated-builder-index-callback branch 2 times, most recently from 8014b57 to 6904036 Compare October 16, 2025 14:28
@victorsanni victorsanni requested a review from Piinks October 20, 2025 21:53
@rkishan516 rkishan516 force-pushed the seperated-builder-index-callback branch from 2851b13 to 7cce0fc Compare October 21, 2025 01:10
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible we might want to keep the original callback since it is used the keep track of children when they are re-ordered? There is an open pending PR that add a separated constructor to the reorderable list classes.

@Piinks
Copy link
Contributor

Piinks commented Oct 24, 2025

cc @chunhtai who might know if we need to preserve the original callback.

@Piinks Piinks requested a review from chunhtai October 24, 2025 23:15
Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chunhtai
Copy link
Contributor

chunhtai commented Nov 4, 2025

I see no good reason to preserve the original callback. since we don't provide a way to build different separator based on index, and you can't swap a separator's location with other item.

@rkishan516 rkishan516 force-pushed the seperated-builder-index-callback branch from 7cce0fc to 8ef53d1 Compare November 5, 2025 01:31
@github-actions github-actions bot removed the c: tech-debt Technical debt, code quality, testing, etc. label Nov 5, 2025
@rkishan516
Copy link
Contributor Author

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@victorsanni
Copy link
Contributor

Can you add the migration guide to the PR description so it is easy to find?

@rkishan516 rkishan516 added this pull request to the merge queue Nov 7, 2025
Merged via the queue into flutter:master with commit 8308135 Nov 7, 2025
74 checks passed
@rkishan516 rkishan516 deleted the seperated-builder-index-callback branch November 7, 2025 01:43
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 7, 2025
… for seperated named constructor in ListView and SliverList (flutter/flutter#174491)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 7, 2025
… for seperated named constructor in ListView and SliverList (flutter/flutter#174491)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 7, 2025
… for seperated named constructor in ListView and SliverList (flutter/flutter#174491)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 8, 2025
… for seperated named constructor in ListView and SliverList (flutter/flutter#174491)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 9, 2025
… for seperated named constructor in ListView and SliverList (flutter/flutter#174491)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 9, 2025
… for seperated named constructor in ListView and SliverList (flutter/flutter#174491)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 11, 2025
… for seperated named constructor in ListView and SliverList (flutter/flutter#174491)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 11, 2025
… for seperated named constructor in ListView and SliverList (flutter/flutter#174491)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 11, 2025
… for seperated named constructor in ListView and SliverList (flutter/flutter#174491)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 12, 2025
… for seperated named constructor in ListView and SliverList (flutter/flutter#174491)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 12, 2025
… for seperated named constructor in ListView and SliverList (flutter/flutter#174491)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 12, 2025
… for seperated named constructor in ListView and SliverList (flutter/flutter#174491)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 12, 2025
… for seperated named constructor in ListView and SliverList (flutter/flutter#174491)
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Nov 12, 2025
…10408)

Manual roll requested by [email protected]

flutter/flutter@31a8481...ee23168

2025-11-07 [email protected] Roll Packages from f13bad3 to 3caa48b (5 revisions) (flutter/flutter#178164)
2025-11-07 [email protected] Fix text input actions in DropdownMenu. (flutter/flutter#177313)
2025-11-07 [email protected] Roll Skia from f838c4b31edb to 581d1ecd5029 (1 revision) (flutter/flutter#178157)
2025-11-07 [email protected] Roll Skia from eb3c5b280ae6 to f838c4b31edb (3 revisions) (flutter/flutter#178149)
2025-11-07 [email protected] Roll Skia from 360fe72b5bf4 to eb3c5b280ae6 (1 revision) (flutter/flutter#178147)
2025-11-07 [email protected] Roll Skia from 116f237bb39d to 360fe72b5bf4 (4 revisions) (flutter/flutter#178146)
2025-11-07 [email protected] Roll Fuchsia Linux SDK from cm88aTLui5yorSGYQ... to qDVe2mrpSgQdxra7p... (flutter/flutter#178144)
2025-11-07 [email protected] fix: findChildIndexCallback to take seperators into account for seperated named constructor in ListView and SliverList (flutter/flutter#174491)
2025-11-06 [email protected] [web] Remove unnecessary android_sdk dep (flutter/flutter#178078)
2025-11-06 [email protected] Add haptic notifications support. (flutter/flutter#177721)
2025-11-06 [email protected] Allow label to be used to compute InputDecorator Intrinsic width (flutter/flutter#178101)
2025-11-06 [email protected] Respect product flavor abiFilters by adding a `disable-abi-filtering` Android project flag. (flutter/flutter#177753)
2025-11-06 [email protected] Use aria-hidden attribute for platform view accessibility on web (flutter/flutter#177969)
2025-11-06 [email protected] [tool] Fix IP parsing by using Uri constructor (flutter/flutter#178083)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
IvoneDjaja pushed a commit to IvoneDjaja/flutter that referenced this pull request Nov 22, 2025
…ated named constructor in ListView and SliverList (flutter#174491)

FindChildIndexCallback to take seperators into account for seperated
named constructor in ListView and SliverList
fixes: flutter#174261

## Migration guide

flutter/website#12636

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…ated named constructor in ListView and SliverList (flutter#174491)

FindChildIndexCallback to take seperators into account for seperated
named constructor in ListView and SliverList
fixes: flutter#174261

## Migration guide

flutter/website#12636

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ListView.separated findChildIndexCallback doesn't take separators into account

4 participants