Skip to content

Commit 6937b0c

Browse files
Migrate to null aware elements - Part 3 (flutter#172307)
<!-- 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 null checks with null aware elements - part 3 Part of flutter#172188 ## 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]. <!-- 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
1 parent af3434b commit 6937b0c

File tree

9 files changed

+9
-25
lines changed

9 files changed

+9
-25
lines changed

packages/flutter_tools/lib/src/android/android_sdk.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class AndroidSdk {
185185
final String? avdHome = globals.platform.environment['ANDROID_AVD_HOME'];
186186
final String? home = globals.platform.environment['HOME'];
187187
final searchPaths = <String>[
188-
if (avdHome != null) avdHome,
188+
?avdHome,
189189
if (home != null) globals.fs.path.join(home, '.android', 'avd'),
190190
];
191191

packages/flutter_tools/lib/src/compile.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ class KernelCompiler {
370370
// See: https://github.com/flutter/flutter/issues/103994
371371
'--verbosity=error',
372372
...?extraFrontEndOptions,
373-
if (mainUri != null) mainUri else '--native-assets-only',
373+
mainUri ?? '--native-assets-only',
374374
];
375375

376376
_logger.printTrace(command.join(' '));

packages/flutter_tools/lib/src/debug_adapters/flutter_test_adapter.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,7 @@ class FlutterTestDebugAdapter extends FlutterBaseDebugAdapter with TestAdapter {
6464
toolArgs.removeRange(0, math.min(removeArgs, toolArgs.length));
6565
}
6666

67-
final processArgs = <String>[
68-
...toolArgs,
69-
...?args.toolArgs,
70-
if (program != null) program,
71-
...?args.args,
72-
];
67+
final processArgs = <String>[...toolArgs, ...?args.toolArgs, ?program, ...?args.args];
7368

7469
await launchAsProcess(executable: executable, processArgs: processArgs, env: args.env);
7570

packages/flutter_tools/lib/src/doctor.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,10 +651,7 @@ class FlutterValidator extends DoctorValidator {
651651
List<ValidationMessage> _validateRequiredBinaries(String flutterRoot) {
652652
final ValidationMessage? flutterWarning = _validateSdkBinary('flutter', flutterRoot);
653653
final ValidationMessage? dartWarning = _validateSdkBinary('dart', flutterRoot);
654-
return <ValidationMessage>[
655-
if (flutterWarning != null) flutterWarning,
656-
if (dartWarning != null) dartWarning,
657-
];
654+
return <ValidationMessage>[?flutterWarning, ?dartWarning];
658655
}
659656

660657
/// Return a warning if the provided [binary] on the user's path does not

packages/flutter_tools/lib/src/project.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,7 @@ class FlutterProject {
165165
if (android.existsSync()) {
166166
final String? applicationId = android.applicationId;
167167
final String? group = android.group;
168-
candidates.addAll(<String>[
169-
if (applicationId != null) applicationId,
170-
if (group != null) group,
171-
]);
168+
candidates.addAll(<String>[?applicationId, ?group]);
172169
}
173170
if (example.android.existsSync()) {
174171
final String? applicationId = example.android.applicationId;

packages/flutter_tools/lib/src/test/flutter_web_platform.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ class FlutterWebPlatform extends PlatformPlugin {
661661
@override
662662
Future<void> close() => _closeMemo.runOnce(() async {
663663
await Future.wait<void>(<Future<dynamic>>[
664-
if (_browserManager != null) _browserManager!.close(),
664+
?_browserManager?.close(),
665665
_server.close(),
666666
_testGoldenComparator.close(),
667667
]);

packages/flutter_tools/lib/src/version.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,7 @@ abstract class FlutterVersion {
223223

224224
String _getTimeSinceCommit({String? revision}) {
225225
return _git
226-
.logSync([
227-
'-n',
228-
'1',
229-
'--pretty=format:%ar',
230-
if (revision != null) revision,
231-
], workingDirectory: flutterRoot)
226+
.logSync(['-n', '1', '--pretty=format:%ar', ?revision], workingDirectory: flutterRoot)
232227
.stdout
233228
.trim();
234229
}

packages/flutter_tools/test/commands.shard/permeable/create_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4911,7 +4911,7 @@ Future<void> _runFlutterTest(Directory workingDir, {String? target}) async {
49114911

49124912
await _getPackages(workingDir);
49134913

4914-
final args = <String>[flutterToolsSnapshotPath, 'test', '--no-color', if (target != null) target];
4914+
final args = <String>[flutterToolsSnapshotPath, 'test', '--no-color', ?target];
49154915

49164916
final ProcessResult exec = await Process.run(
49174917
globals.artifacts!.getArtifactPath(Artifact.engineDartBinary),

packages/flutter_tools/test/commands.shard/permeable/widget_preview/widget_preview_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ void main() {
154154
...?arguments,
155155
'--no-launch-previewer',
156156
'--verbose',
157-
if (rootProject != null) rootProject.path,
157+
?rootProject?.path,
158158
]);
159159
final Directory widgetPreviewScaffoldDir = widgetPreviewScaffoldFromRootProject(
160160
rootProject: rootProject ?? current,

0 commit comments

Comments
 (0)