Deprecate onReorder callback#178242
Conversation
There was a problem hiding this comment.
Code Review
This pull request deprecates the onReorder callback across ReorderableList, SliverReorderableList, and ReorderableListView, introducing a simpler onReorderItem callback that handles index correction internally. The implementation correctly maintains backward compatibility by prioritizing the old callback if provided. The examples and tests are thoroughly updated, and new tests have been added to validate the new behavior and the deprecation path. Overall, this is a solid improvement. I've added a couple of suggestions to address minor code duplication and a redundant null-safe call to enhance maintainability.
a0c1c36 to
dfffdbe
Compare
dfffdbe to
ad634ae
Compare
|
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 Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
dkwingsmt
left a comment
There was a problem hiding this comment.
Generally looking good. Thank you!
ad634ae to
025764e
Compare
|
I updated the PR, so that the new parameter is nullable. I also added new tests for the assert and repurposed the old tests that I wrote, for testing if the old callback still works (if a user were to provide it). Also cleaned up one of Gemini's suggestions, because some code was duplicated. |
|
The customer in the google failure has a bad test - it's a screenshot that contains a real date, must be new since they did not account for the date changing everyday. We'll get it fixed. (after today, everyone is OOO for the holiday today) :) |
Thanks for investigating! Let me know when I can rebase :) |
|
I will start on the migration guide on the website tomorrow. |
Roll Flutter from da72d5936d69 to 1d9d6a9a5ef6 (33 revisions) flutter/flutter@da72d59...1d9d6a9 2026-01-30 [email protected] enable enhanced debugging for GLES playground (flutter/flutter#181157) 2026-01-30 [email protected] Make the Windows windowing_test in .ci.yaml have bringup as false (flutter/flutter#181664) 2026-01-30 [email protected] Roll Packages from cd4fd61 to 510dd40 (4 revisions) (flutter/flutter#181726) 2026-01-30 [email protected] Roll Skia from edbf7e9eb846 to 4745eb2fe837 (1 revision) (flutter/flutter#181725) 2026-01-30 [email protected] Enhance error handling of WidgetsBindingObserver callbacks (flutter/flutter#181174) 2026-01-30 [email protected] Roll Skia from 05d3cb9d2be9 to edbf7e9eb846 (2 revisions) (flutter/flutter#181715) 2026-01-30 [email protected] Roll Skia from c198e5fa9cd9 to 05d3cb9d2be9 (1 revision) (flutter/flutter#181712) 2026-01-30 [email protected] Roll Dart SDK from 920b7e24583e to 2703fd9733ce (2 revisions) (flutter/flutter#181693) 2026-01-30 [email protected] Roll Skia from b9f40c193e7a to c198e5fa9cd9 (6 revisions) (flutter/flutter#181692) 2026-01-30 [email protected] Roll pub packages (flutter/flutter#181690) 2026-01-30 [email protected] Extend the Windows tool_integration_tests_2_9 shard timeout to 1 hour (flutter/flutter#181678) 2026-01-29 [email protected] Add `android_sdk` dependency to `android_engine_opengles_tests` (flutter/flutter#181681) 2026-01-29 [email protected] Roll Dart SDK from a0685c8e946b to 920b7e24583e (3 revisions) (flutter/flutter#181680) 2026-01-29 [email protected] Roll Skia from 128b5213711e to b9f40c193e7a (14 revisions) (flutter/flutter#181675) 2026-01-29 [email protected] [Impeller] Ensure that HostBuffers/DeviceBuffers allocated by RendererTest tests are valid for the lifetime of the RenderPass (flutter/flutter#181635) 2026-01-29 [email protected] [Impeller] Fix off-by-one indices in the SimilarPointPair/SimilarPointTrio functions used by ShadowPathGeometryTest (flutter/flutter#181623) 2026-01-29 [email protected] 180162 fix radio list tile and switch list tile accept widget states controller (flutter/flutter#180367) 2026-01-29 [email protected] Remove unused test file (flutter/flutter#181671) 2026-01-29 [email protected] Roll libpng to version 1.6.54 (flutter/flutter#181625) 2026-01-29 [email protected] Remove nonstandard ndkpath for `hybrid_android_views` integration test (flutter/flutter#181666) 2026-01-29 [email protected] Add TestWidgetsApp utility and refactor widget tests to use WidgetsApp (flutter/flutter#180456) 2026-01-29 [email protected] Add `TestTextField` and migrate tests (flutter/flutter#180494) 2026-01-29 [email protected] Merge changelog for 3.38.9 (flutter/flutter#181668) 2026-01-29 [email protected] [flutter_tools] Deprecate `plugin_ffi` template (flutter/flutter#181588) 2026-01-29 [email protected] Deprecate onReorder callback (flutter/flutter#178242) 2026-01-29 [email protected] [web] Use defensive null check in text editing placeElement (flutter/flutter#180795) 2026-01-29 [email protected] Roll Packages from 1cb2148 to cd4fd61 (4 revisions) (flutter/flutter#181663) 2026-01-29 [email protected] Roll Skia from 89df65f8324c to 128b5213711e (2 revisions) (flutter/flutter#181651) 2026-01-29 [email protected] [hooks] Don't run build hooks for code assets in `flutter run` (flutter/flutter#181542) 2026-01-29 [email protected] Roll Dart SDK from f10dcbfca98f to a0685c8e946b (5 revisions) (flutter/flutter#181653) 2026-01-29 [email protected] Fixes getUniformX for Vulkan (flutter/flutter#181286) 2026-01-29 [email protected] Roll Fuchsia Linux SDK from adhoq9ouVRh0xzkm3... to isy1ARvK-3bsvtfc-... (flutter/flutter#181641) 2026-01-29 [email protected] Add isDark, isLight, and isSystem getters to ThemeMode (flutter/flutter#181475) 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: ...
This pull request deprecates the old `onReorder` callback of `ReorderableList` / `SliverReorderableList` / `ReorderableListView`, in favor of a new callback, `onReorderItem`, that does the index correction as mentioned in the docs at https://api.flutter.dev/flutter/widgets/ReorderCallback.html I added tests to ensure that the old callback is preferred when both are provided and tests that assert that the new callback does the index correction correctly. I also noticed that some tests used empty callbacks for `onReorder`, those have been updated to use wildcards in a consistent manner. I did not opt into making a design doc, since the change itself is very small, that will also be apparent in the migration guide that I am going to write. Fixes flutter#127901 Fixes flutter#169878 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* TODO: add a migration guide on the website ## 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]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --------- Co-authored-by: Tong Mu <[email protected]> Co-authored-by: Victor Sanni <[email protected]>
_Description of what this PR is changing or adding, and why:_ This PR adds a migration guide for PR flutter/flutter#178242 since that change is not supported by `dart fix`. _Issues fixed by this PR (if any):_ Related to flutter/flutter#127901 Related to flutter/flutter#169878 _PRs or commits this PR depends on (if any):_ flutter/flutter#178242 --------- Co-authored-by: Shams Zakhour <[email protected]> Co-authored-by: Parker Lougheed <[email protected]>
This pull request deprecates the old `onReorder` callback of `ReorderableList` / `SliverReorderableList` / `ReorderableListView`, in favor of a new callback, `onReorderItem`, that does the index correction as mentioned in the docs at https://api.flutter.dev/flutter/widgets/ReorderCallback.html I added tests to ensure that the old callback is preferred when both are provided and tests that assert that the new callback does the index correction correctly. I also noticed that some tests used empty callbacks for `onReorder`, those have been updated to use wildcards in a consistent manner. I did not opt into making a design doc, since the change itself is very small, that will also be apparent in the migration guide that I am going to write. Fixes flutter#127901 Fixes flutter#169878 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* TODO: add a migration guide on the website ## 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]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --------- Co-authored-by: Tong Mu <[email protected]> Co-authored-by: Victor Sanni <[email protected]>
This pull request deprecates the old `onReorder` callback of `ReorderableList` / `SliverReorderableList` / `ReorderableListView`, in favor of a new callback, `onReorderItem`, that does the index correction as mentioned in the docs at https://api.flutter.dev/flutter/widgets/ReorderCallback.html I added tests to ensure that the old callback is preferred when both are provided and tests that assert that the new callback does the index correction correctly. I also noticed that some tests used empty callbacks for `onReorder`, those have been updated to use wildcards in a consistent manner. I did not opt into making a design doc, since the change itself is very small, that will also be apparent in the migration guide that I am going to write. Fixes flutter#127901 Fixes flutter#169878 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* TODO: add a migration guide on the website ## 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]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --------- Co-authored-by: Tong Mu <[email protected]> Co-authored-by: Victor Sanni <[email protected]>
This pull request deprecates the old
onReordercallback ofReorderableList/SliverReorderableList/ReorderableListView, in favor of a new callback,onReorderItem, that does the index correction as mentioned in the docs at https://api.flutter.dev/flutter/widgets/ReorderCallback.htmlI added tests to ensure that the old callback is preferred when both are provided and tests that assert that the new callback does the index correction correctly. I also noticed that some tests used empty callbacks for
onReorder, those have been updated to use wildcards in a consistent manner.I did not opt into making a design doc, since the change itself is very small, that will also be apparent in the migration guide that I am going to write.
Fixes #127901
Fixes #169878
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Migration guide: flutter/website#13012
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.