Implementing null-aware operators throughout the repository (#143804)

This pull request fixes #143803 by taking advantage of Dart's null-aware operators.

And unlike `switch` expressions ([9 PRs](https://github.com/flutter/flutter/pull/143634) and counting), the Flutter codebase is already fantastic when it comes to null-aware coding. After refactoring the entire repo, all the changes involving `?.` and `??` can fit into a single pull request.
This commit is contained in:
Nate
2024-02-23 12:02:22 -07:00
committed by GitHub
parent 39585e66c1
commit c53a18f4e4
55 changed files with 93 additions and 365 deletions

View File

@@ -91,11 +91,7 @@ Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoSyncStar(List<Inlin
workingText += info.text;
workingLabel ??= '';
final String? infoSemanticsLabel = info.semanticsLabel;
if (infoSemanticsLabel != null) {
workingLabel += infoSemanticsLabel;
} else {
workingLabel += info.text;
}
workingLabel += infoSemanticsLabel ?? info.text;
}
}
assert(workingLabel != null);
@@ -115,11 +111,7 @@ Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoList(List<InlineSpa
workingText += info.text;
workingLabel ??= '';
final String? infoSemanticsLabel = info.semanticsLabel;
if (infoSemanticsLabel != null) {
workingLabel += infoSemanticsLabel;
} else {
workingLabel += info.text;
}
workingLabel += infoSemanticsLabel ?? info.text;
}
}
assert(workingLabel != null);