-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Refactor: Convert Title widget to StatefulWidget #176010
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
Refactor: Convert Title widget to StatefulWidget #176010
Conversation
The Title widget was previously a StatelessWidget. This change converts it to a StatefulWidget to allow it to update the application switcher description when its `title` or `color` properties change. - The `_updateChrome` method is introduced to encapsulate the call to `SystemChrome.setApplicationSwitcherDescription`. - `initState` now calls `_updateChrome` to set the initial description. - `didUpdateWidget` checks if `title` or `color` have changed and calls `_updateChrome` accordingly. - The `build` method now simply returns `widget.child`. - Property access in `debugFillProperties` is updated to use `widget.propertyName`.
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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 correctly refactors the Title widget from a StatelessWidget to a StatefulWidget to handle dynamic updates of the application switcher description. The logic is sound, introducing initState and didUpdateWidget to manage side effects. I have a couple of suggestions to align the code with standard Flutter conventions for state lifecycle methods, which will improve robustness.
|
I don't know whom to tag. |
|
@kazbeksultanov in my experience review always takes at least 2 weeks, but asking on the official Discord (not Flutter Dev) can help with getting someone assigned |
|
I hoped that because the PR is so small and not complex, it will be picked up faster. @benthillerkus, thanks for comment 🙏 |
justinmc
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.
I'm on board with making this change, but please add a test that verifies that SystemChrome.setApplicationSwitcherDescription is called only when title or color change.
The documentation for the `Title` widget was describing its implementation details. This change removes the redundant comment. Additionally, new tests are added to verify that `SystemChrome.setApplicationSwitcherDescription` is called only when the `title` or `color` properties actually change, and not on every rebuild with the same values.
|
@justinmc I reverted the doc comment on Title Widget and added tests. |
chunhtai
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.
LGTM, I saw the comment in original issue, this approach LGTM
|
@chunhtai what should I do next? |
|
@benthillerkus @chunhtai @chinmaygarde anyone could add the |
|
Any suggestions how to proceed with this PR will be appreciated guys 😅 |
justinmc
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.
Missing a teardown in the tests, otherwise this looks good.
Sorry for the slow response here, we usually check PRs once per week. Feel free to ping me on the Flutter Discord once this is ready for re-review if I'm not seeing it.
justinmc
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.
LGTM 👍 . Thanks for following up! I see some failures, but they look like flakes. I'm rerunning them.
|
autosubmit label was removed for flutter/flutter/176010, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/176010, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
the error doesn't seem to be related (internal only)https://fusion2.corp.google.com/presubmit/820740220/OCL:820740220:BASE:820744284:1760722773976:e142c2d5;groups=PossiblyNewlyFailing/targets |
Roll Flutter from a873a27 to 891d7d5 (32 revisions) flutter/flutter@a873a27...891d7d5 2025-10-18 engine-flutter-autoroll@skia.org Roll Skia from b4981b621a54 to 74df18176924 (1 revision) (flutter/flutter#177204) 2025-10-18 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from ZHuhfPyyV-LcKDLRh... to M8WT2GMY46e_0fFho... (flutter/flutter#177200) 2025-10-18 59215665+davidhicks980@users.noreply.github.com [material/dropdown_menu.dart] Refactor _RenderDropdownMenuBody.computeDryLayout (flutter/flutter#176503) 2025-10-18 engine-flutter-autoroll@skia.org Roll Skia from 579c72d673dd to b4981b621a54 (2 revisions) (flutter/flutter#177199) 2025-10-17 engine-flutter-autoroll@skia.org Roll Skia from 89a8bc508a7c to 579c72d673dd (15 revisions) (flutter/flutter#177194) 2025-10-17 paulberry@google.com [test_fixes] Enable `deprecated_member_use_from_same_package`. (flutter/flutter#177183) 2025-10-17 jhy03261997@gmail.com [a11y] fix table semantics cache for cells (flutter/flutter#177073) 2025-10-17 mdebbar@google.com [web] Self-cleaning service worker (flutter/flutter#176834) 2025-10-17 engine-flutter-autoroll@skia.org Manual roll Skia from 2d9df7c70b6f to 89a8bc508a7c (24 revisions) (flutter/flutter#177182) 2025-10-17 matt.kosarek@canonical.com Fixing WindowManagerTest::DialogCanNeverBeFullscreen possibly hanging (flutter/flutter#177179) 2025-10-17 jhy03261997@gmail.com [VPAT][A11y][a11y-app] Add a text label to slider. (flutter/flutter#177130) 2025-10-17 engine-flutter-autoroll@skia.org Manual roll Dart SDK from a4485e5ef821 to a66f334fee2a (5 revisions) (flutter/flutter#177142) 2025-10-17 jhy03261997@gmail.com [web][a11y] Fix the semantics tree reconstruction logic when a subtree is reparented to another node. (flutter/flutter#177069) 2025-10-17 rmolivares@renzo-olivares.dev `SelectableRegion` should use flutter rendered menu on the web for Android and iOS (flutter/flutter#177122) 2025-10-17 kazbek.sultanov.doc@gmail.com Refactor: Convert Title widget to StatefulWidget (flutter/flutter#176010) 2025-10-17 jessiewong401@gmail.com Bump AGP, KGP, Gradle Templates (flutter/flutter#176858) 2025-10-17 engine-flutter-autoroll@skia.org Roll Packages from 835dccb to 3747006 (3 revisions) (flutter/flutter#177170) 2025-10-17 codefu@google.com Mark windows_unopt test as flakey (flutter/flutter#177173) 2025-10-17 rmolivares@renzo-olivares.dev Tapping outside of `SelectableRegion` should dismiss the selection (flutter/flutter#176843) 2025-10-17 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from _dd0Jv50H0oUI2Ad8... to ZHuhfPyyV-LcKDLRh... (flutter/flutter#177137) 2025-10-17 jason-simmons@users.noreply.github.com Manual roll Dart to a4485e5ef821 (3.11.0-25.0.dev) (flutter/flutter#177132) 2025-10-17 ahmedsameha1@gmail.com Make sure that a MenuAcceleratorLabel doesn't crash in 0x0 environment (flutter/flutter#176646) 2025-10-16 ahmedsameha1@gmail.com Make sure that a NavigationRail doesn't crash in 0x0 environment (flutter/flutter#177022) 2025-10-16 ahmedsameha1@gmail.com Make sure that a SubmenuButton doesn't crash in 0x0 environment (flutter/flutter#176535) 2025-10-16 mail@leuchte.net Fix typo in ButtonBar documentation (flutter/flutter#177078) 2025-10-16 ahmedsameha1@gmail.com Make sure that an InkResponse doesn't crash in 0x0 environment (flutter/flutter#175426) 2025-10-16 jessiewong401@gmail.com [Gradle 9] Resolve Gradle 9 Deprecations in flutter/flutter part 1 (flutter/flutter#176865) 2025-10-16 1063596+reidbaker@users.noreply.github.com Revert "Resolve resolve native Flutter dependencies in Android Studio (#167332)" (flutter/flutter#177053) 2025-10-16 engine-flutter-autoroll@skia.org Manual roll Dart SDK from 2d8e0359a767 to 25b6094026e4 (5 revisions) (flutter/flutter#177109) 2025-10-16 maxenceb1207@gmail.com Add textfield prop to SearchAnchor (flutter/flutter#174497) 2025-10-16 p1318k@gmail.com Fix crash when NSAttributedString is passed to insertText on macOS (flutter/flutter#176329) 2025-10-16 jmccandless@google.com Correct basque time format (flutter/flutter#177031) 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 stuartmorgan@google.com,tarrinneal@google.com 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 ...
Fix: flutter#176008 The Title widget was previously a `StatelessWidget`. This change converts it to a `StatefulWidget` to allow it to update the application switcher description when its `title` or `color` properties change. - The `_updateChrome` method is introduced to encapsulate the call to `SystemChrome.setApplicationSwitcherDescription`. - `initState` now calls `_updateChrome` to set the initial description. - `didUpdateWidget` checks if `title` or `color` have changed and calls `_updateChrome` accordingly. - The `build` method now simply returns `widget.child`. - Property access in `debugFillProperties` is updated to use `widget.propertyName`. <!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> *Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.* *List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.* *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* ## 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. 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: Kazbek Sultanov <167094819+kazbek-sultanov-t@users.noreply.github.com>
Fix: #176008
The Title widget was previously a
StatelessWidget. This change converts it to aStatefulWidgetto allow it to update the application switcher description when itstitleorcolorproperties change._updateChromemethod is introduced to encapsulate the call toSystemChrome.setApplicationSwitcherDescription.initStatenow calls_updateChrometo set the initial description.didUpdateWidgetchecks iftitleorcolorhave changed and calls_updateChromeaccordingly.buildmethod now simply returnswidget.child.debugFillPropertiesis updated to usewidget.propertyName.Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.
List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
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.