Skip to content

Conversation

@ValentinVignal
Copy link
Contributor

Follow up of #175396

This PR applies the code change suggestion from gemini review

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-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.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. labels Sep 18, 2025
@ValentinVignal ValentinVignal mentioned this pull request Sep 18, 2025
9 tasks
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 correctly simplifies several if-else blocks into single return statements, which improves code conciseness. I've added suggestions to further simplify these by converting the single-line function bodies into arrow functions, which is a common practice for cleaner code and aligns with the Effective Dart style guide.

Comment on lines 937 to 939
trackVisibility: WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.hovered)) {
return true;
}
return false;
return states.contains(WidgetState.hovered);
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For conciseness, you can use an arrow function (=>) for this single-line function body. This aligns with the Effective Dart style guide.1

              trackVisibility: WidgetStateProperty.resolveWith((Set<WidgetState> states) => states.contains(WidgetState.hovered)),

Style Guide References

Footnotes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@justinmc Do you prefer the arrow function too?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there's any con to using the arrows, but I might be wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great, I updated the code to use expression body in Use expression body

Comment on lines 1086 to 1088
trackVisibility: WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.hovered)) {
return true;
}
return false;
return states.contains(WidgetState.hovered);
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For conciseness, you can use an arrow function (=>) for this single-line function body. This aligns with the Effective Dart style guide.1

              trackVisibility: WidgetStateProperty.resolveWith((Set<WidgetState> states) => states.contains(WidgetState.hovered)),

Style Guide References

Footnotes

Comment on lines 1151 to 1153
trackVisibility: WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.hovered)) {
return true;
}
return false;
return states.contains(WidgetState.hovered);
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For conciseness, you can use an arrow function (=>) for this single-line function body. This aligns with the Effective Dart style guide.1

              trackVisibility: WidgetStateProperty.resolveWith((Set<WidgetState> states) => states.contains(WidgetState.hovered)),

Style Guide References

Footnotes

Comment on lines 41 to 43
trackVisibility: WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.hovered)) {
return true;
}
return false;
return states.contains(WidgetState.hovered);
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For conciseness, you can use an arrow function (=>) for this single-line function body. This aligns with the Effective Dart style guide.1

              trackVisibility: WidgetStateProperty.resolveWith((Set<WidgetState> states) => states.contains(WidgetState.hovered)),

Style Guide References

Footnotes

Comment on lines 387 to 389
trackVisibility: WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.hovered)) {
return true;
}
return false;
return states.contains(WidgetState.hovered);
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For conciseness, you can use an arrow function (=>) for this single-line function body. This aligns with the Effective Dart style guide.1

              trackVisibility: WidgetStateProperty.resolveWith((Set<WidgetState> states) => states.contains(WidgetState.hovered)),

Style Guide References

Footnotes

Comment on lines 489 to 491
trackVisibility: WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.hovered)) {
return true;
}
return false;
return states.contains(WidgetState.hovered);
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For conciseness, you can use an arrow function (=>) for this single-line function body. This aligns with the Effective Dart style guide.1

            trackVisibility: WidgetStateProperty.resolveWith((Set<WidgetState> states) => states.contains(WidgetState.hovered)),

Style Guide References

Footnotes

Comment on lines 783 to 785
WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.hovered)) {
return true;
}
return false;
return states.contains(WidgetState.hovered);
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For conciseness, you can use an arrow function (=>) for this single-line function body. This aligns with the Effective Dart style guide.1

        WidgetStateProperty.resolveWith((Set<WidgetState> states) => states.contains(WidgetState.hovered)),

Style Guide References

Footnotes

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.

This PR qualifies for a test exemption.

Comment on lines 937 to 939
trackVisibility: WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.hovered)) {
return true;
}
return false;
return states.contains(WidgetState.hovered);
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there's any con to using the arrows, but I might be wrong.

@ValentinVignal ValentinVignal force-pushed the flutter/simplify-if-else-block-into-single-return-statement branch from 6c2d429 to 20cf1b7 Compare September 23, 2025 04:52
@dkwingsmt dkwingsmt self-requested a review October 1, 2025 18:13
Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for the cleanup!

@ValentinVignal ValentinVignal added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 7, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 7, 2025

autosubmit label was removed for flutter/flutter/175574, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 7, 2025
@ValentinVignal ValentinVignal force-pushed the flutter/simplify-if-else-block-into-single-return-statement branch from 20cf1b7 to 5fc8562 Compare October 7, 2025 06:36
@ValentinVignal ValentinVignal added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 7, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Oct 7, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Oct 7, 2025
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 7, 2025
@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 8, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Oct 8, 2025
Merged via the queue into flutter:master with commit 6e5d007 Oct 8, 2025
76 of 77 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 9, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 15, 2025
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
Follow up of flutter#175396

This PR applies the code change suggestion from gemini review

## 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].
- [ ] 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.

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. 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.

3 participants