-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add onReorder callback migration guide #13012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add onReorder callback migration guide #13012
Conversation
Summary of ChangesHello @navaronbracke, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a comprehensive migration guide to assist developers in transitioning from the deprecated Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this 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 introduces a well-written and clear migration guide for the onReorder callback deprecation. The document effectively explains the background of the change, provides a step-by-step migration process, and includes helpful code examples for all affected widgets. This will be a great resource for developers. I have one minor suggestion to make the document slightly more concise.
| {% render "docs/main-api.md", site: site %} | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see this macro in other breaking change documents. I have remove it from the PR, but can a writer double check if I need to omit it, or keep it somewhere?
dkwingsmt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor suggestions. Take whichever you see fit. LGTM overall. Thank you!
src/content/release/breaking-changes/deprecate-onreorder-callback.md
Outdated
Show resolved
Hide resolved
| ``` | ||
|
|
||
| ```dart | ||
| ReorderableListView.builder( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need to enumerate all 4 cases. Taking one of them for example is clear enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to add all sample variants, since all of these widgets need the migration.
I think that is clearer for someone who needs to migrate a lot of code that is affected?
I'm fine with keeping these or removing them, but I would prefer being a little verbose here, for the sake of the reader.
| } | ||
| ) | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be helpful to provide an extra version that explains "what if your current onReorder doesn't have that if clause".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an example that defers onReorder to a callback function to show what to do then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what this is used for... I was probably misunderstood. What I meant was:
If the current
onReorderdoesn't use the saidifclause, migrate it in this way:
Code before migration:
ReorderableListView(
onReorder: (int oldIndex, int newIndex) {
...
}
)Code after migration:
ReorderableListView(
onReorderItem: (int oldIndex, int newIndex) {
if (oldIndex < newIndex) {
newIndex += 1;
}
...
}
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of the new onReorderItem is that you do not need the
if (oldIndex < newIndex) {
newIndex += 1;
}
in your onReorderItem callback, because it is done for you inside the widget.
If you did not have
if (oldIndex < newIndex) {
newIndex += 1;
}
anywhere in your onReorder callback, then you actually had a bug in your code (this is why people probably filed issues on Github, because they forgot to add it?)
There was a note in the docs about this before (which I now removed, since it no longer applies with the new callback)
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
Presubmit checklist
If you are unwilling, or unable, to sign the CLA, even for a tiny, one-word PR, please file an issue instead of a PR.
If this PR is not meant to land until a future stable release, mark it as draft with an explanation.
This PR follows the Google Developer Documentation Style Guidelines—for example, it doesn't use i.e. or e.g., and it avoids I and we (first-person pronouns).
This PR uses semantic line breaks
of 80 characters or fewer.
cc @dkwingsmt