Harkirat Singh [SSW] 50bae580d4
Adopt Null-Aware Elements in packages/flutter/lib/src/material (#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 #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
https://github.com/flutter/flutter/issues/172188#issuecomment-3076061395,
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
2025-07-18 20:00:09 +00:00
..
2025-07-18 00:32:29 +00:00