-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Adopt Null-Aware Elements in packages/flutter/lib/src/material
#172285
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
Adopt Null-Aware Elements in packages/flutter/lib/src/material
#172285
Conversation
|
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. |
|
Summary by Copilot Simplification of conditional rendering:
|
|
Oh my god. All tests are running again. My bad, to not to dart format before creating pr |
tirth-patel-nc
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.
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! Thank you! Let me jut get a test-exempt stamp, sent out for review.
|
test-exempt: code refactor with no semantic change |
|
This is such a crazy start to the weekend here in Australia. So awesome 😎. PR gets merged with notable commit mention. Life is good 🎉. |
flutter/flutter@440713c...70a3c3c 2025-07-20 [email protected] Add optional splashColor property to ExpansionTile (flutter/flutter#172224) 2025-07-20 [email protected] Roll Fuchsia Linux SDK from 6agRTm-nf09sDmfQG... to 8MyOdk7FEK-MqkzIF... (flutter/flutter#172420) 2025-07-19 [email protected] Roll Dart SDK from ca7224f7dfd7 to a821b47e7a4d (1 revision) (flutter/flutter#172407) 2025-07-19 [email protected] Roll Dart SDK from 9982ab49440a to ca7224f7dfd7 (2 revisions) (flutter/flutter#172401) 2025-07-19 [email protected] fix: produce pom/jar files with content_hash (flutter/flutter#172378) 2025-07-18 [email protected] Roll Dart SDK from fe2232bd5b9f to 9982ab49440a (2 revisions) (flutter/flutter#172393) 2025-07-18 [email protected] Roll Fuchsia Linux SDK from HXdm7P0a4ZJVm_TE-... to 6agRTm-nf09sDmfQG... (flutter/flutter#172392) 2025-07-18 [email protected] Adopt Null-Aware Elements in `packages/flutter/lib/src/material` (flutter/flutter#172285) 2025-07-18 [email protected] Recommend using Flutter feature flags over platform-specific configs (flutter/flutter#172324) 2025-07-18 [email protected] TestTextInput should reset its key handler between tests (flutter/flutter#172323) 2025-07-18 [email protected] Mark Mac_* tool_tests_commands as bringup to unblock tree (flutter/flutter#172388) 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
…tter#172285) <!-- 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 --> This pr aims to complete flutter#172188 by refactoring all files in `packages/flutter/lib/src/material` to adopt Dart 3.8's null-aware elements feature. Each file was refactored in its own commit for clear, incremental changes and traceable history. ### Motivation Following the flutter#172188 (comment), this PR is intentionally scoped to a single folder to keep the review surface manageable. Migrating package by package enables more focused code review, easier troubleshooting, and a safer incremental adoption of the new language feature. ### Approach - **Scope:** Only files under `packages/flutter/lib/src/material` have been refactored. - **Commits:** Each file refactored in its own commit for granularity and traceability. - **Code style:** Changed list element conditionals to use null-aware elements where applicable, improving readability and reducing verbosity. ### Testing - All existing tests were run after each change. - All tests passed except for `chip_test.dart`, which was already failing before these changes and continues to fail after. No new test failures were introduced by this PR. ### Additional Notes - No functional or behavioral changes were made; this is a pure refactor for code clarity and modernization. - Adhering to the incremental migration strategy proposed in the referenced issue for safer and more effective review. --- Ready for 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]. - [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. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- 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
…r#9653) flutter/flutter@440713c...70a3c3c 2025-07-20 [email protected] Add optional splashColor property to ExpansionTile (flutter/flutter#172224) 2025-07-20 [email protected] Roll Fuchsia Linux SDK from 6agRTm-nf09sDmfQG... to 8MyOdk7FEK-MqkzIF... (flutter/flutter#172420) 2025-07-19 [email protected] Roll Dart SDK from ca7224f7dfd7 to a821b47e7a4d (1 revision) (flutter/flutter#172407) 2025-07-19 [email protected] Roll Dart SDK from 9982ab49440a to ca7224f7dfd7 (2 revisions) (flutter/flutter#172401) 2025-07-19 [email protected] fix: produce pom/jar files with content_hash (flutter/flutter#172378) 2025-07-18 [email protected] Roll Dart SDK from fe2232bd5b9f to 9982ab49440a (2 revisions) (flutter/flutter#172393) 2025-07-18 [email protected] Roll Fuchsia Linux SDK from HXdm7P0a4ZJVm_TE-... to 6agRTm-nf09sDmfQG... (flutter/flutter#172392) 2025-07-18 [email protected] Adopt Null-Aware Elements in `packages/flutter/lib/src/material` (flutter/flutter#172285) 2025-07-18 [email protected] Recommend using Flutter feature flags over platform-specific configs (flutter/flutter#172324) 2025-07-18 [email protected] TestTextInput should reset its key handler between tests (flutter/flutter#172323) 2025-07-18 [email protected] Mark Mac_* tool_tests_commands as bringup to unblock tree (flutter/flutter#172388) 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
…tter#172285) <!-- 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 --> This pr aims to complete flutter#172188 by refactoring all files in `packages/flutter/lib/src/material` to adopt Dart 3.8's null-aware elements feature. Each file was refactored in its own commit for clear, incremental changes and traceable history. ### Motivation Following the flutter#172188 (comment), this PR is intentionally scoped to a single folder to keep the review surface manageable. Migrating package by package enables more focused code review, easier troubleshooting, and a safer incremental adoption of the new language feature. ### Approach - **Scope:** Only files under `packages/flutter/lib/src/material` have been refactored. - **Commits:** Each file refactored in its own commit for granularity and traceability. - **Code style:** Changed list element conditionals to use null-aware elements where applicable, improving readability and reducing verbosity. ### Testing - All existing tests were run after each change. - All tests passed except for `chip_test.dart`, which was already failing before these changes and continues to fail after. No new test failures were introduced by this PR. ### Additional Notes - No functional or behavioral changes were made; this is a pure refactor for code clarity and modernization. - Adhering to the incremental migration strategy proposed in the referenced issue for safer and more effective review. --- Ready for 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]. - [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. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- 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
…tter#172285) <!-- 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 --> This pr aims to complete flutter#172188 by refactoring all files in `packages/flutter/lib/src/material` to adopt Dart 3.8's null-aware elements feature. Each file was refactored in its own commit for clear, incremental changes and traceable history. ### Motivation Following the flutter#172188 (comment), this PR is intentionally scoped to a single folder to keep the review surface manageable. Migrating package by package enables more focused code review, easier troubleshooting, and a safer incremental adoption of the new language feature. ### Approach - **Scope:** Only files under `packages/flutter/lib/src/material` have been refactored. - **Commits:** Each file refactored in its own commit for granularity and traceability. - **Code style:** Changed list element conditionals to use null-aware elements where applicable, improving readability and reducing verbosity. ### Testing - All existing tests were run after each change. - All tests passed except for `chip_test.dart`, which was already failing before these changes and continues to fail after. No new test failures were introduced by this PR. ### Additional Notes - No functional or behavioral changes were made; this is a pure refactor for code clarity and modernization. - Adhering to the incremental migration strategy proposed in the referenced issue for safer and more effective review. --- Ready for 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]. - [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. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- 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
…tter#172285) <!-- 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 --> This pr aims to complete flutter#172188 by refactoring all files in `packages/flutter/lib/src/material` to adopt Dart 3.8's null-aware elements feature. Each file was refactored in its own commit for clear, incremental changes and traceable history. ### Motivation Following the flutter#172188 (comment), this PR is intentionally scoped to a single folder to keep the review surface manageable. Migrating package by package enables more focused code review, easier troubleshooting, and a safer incremental adoption of the new language feature. ### Approach - **Scope:** Only files under `packages/flutter/lib/src/material` have been refactored. - **Commits:** Each file refactored in its own commit for granularity and traceability. - **Code style:** Changed list element conditionals to use null-aware elements where applicable, improving readability and reducing verbosity. ### Testing - All existing tests were run after each change. - All tests passed except for `chip_test.dart`, which was already failing before these changes and continues to fail after. No new test failures were introduced by this PR. ### Additional Notes - No functional or behavioral changes were made; this is a pure refactor for code clarity and modernization. - Adhering to the incremental migration strategy proposed in the referenced issue for safer and more effective review. --- Ready for 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]. - [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. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- 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

This pr aims to complete #172188 by refactoring all files in
packages/flutter/lib/src/materialto adopt Dart 3.8's null-aware elements feature. Each file was refactored in its own commit for clear, incremental changes and traceable history.Motivation
Following the #172188 (comment), this PR is intentionally scoped to a single folder to keep the review surface manageable. Migrating package by package enables more focused code review, easier troubleshooting, and a safer incremental adoption of the new language feature.
Approach
packages/flutter/lib/src/materialhave been refactored.Testing
chip_test.dart, which was already failing before these changes and continues to fail after. No new test failures were introduced by this PR.Additional Notes
Ready for review! 🚀
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.