Skip to content

Commit 7f17708

Browse files
feat: migrate ios/bitcode.dart to null safety (flutter#92557)
1 parent 9d26386 commit 7f17708

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

packages/flutter_tools/lib/src/ios/bitcode.dart

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.8
6-
75
import '../artifacts.dart';
86
import '../base/common.dart';
97
import '../base/context.dart';
@@ -16,21 +14,23 @@ import '../macos/xcode.dart';
1614
const bool kBitcodeEnabledDefault = false;
1715

1816
Future<void> validateBitcode(BuildMode buildMode, TargetPlatform targetPlatform, EnvironmentType environmentType) async {
19-
final Artifacts localArtifacts = globals.artifacts;
20-
final String flutterFrameworkPath = localArtifacts.getArtifactPath(
17+
final Artifacts? localArtifacts = globals.artifacts;
18+
final String? flutterFrameworkPath = localArtifacts?.getArtifactPath(
2119
Artifact.flutterFramework,
2220
mode: buildMode,
2321
platform: targetPlatform,
2422
environmentType: environmentType,
2523
);
26-
final Xcode xcode = context.get<Xcode>();
24+
final Xcode? xcode = context.get<Xcode>();
2725

28-
final RunResult clangResult = await xcode.clang(<String>['--version']);
29-
final String clangVersion = clangResult.stdout.split('\n').first;
30-
final String engineClangVersion = globals.plistParser.getValueFromFile(
31-
globals.fs.path.join(flutterFrameworkPath, 'Info.plist'),
32-
'ClangVersion',
33-
);
26+
final RunResult? clangResult = await xcode?.clang(<String>['--version']);
27+
final String? clangVersion = clangResult?.stdout.split('\n').first;
28+
final String? engineClangVersion = flutterFrameworkPath == null
29+
? null
30+
: globals.plistParser.getValueFromFile(
31+
globals.fs.path.join(flutterFrameworkPath, 'Info.plist'),
32+
'ClangVersion',
33+
);
3434
final Version engineClangSemVer = _parseVersionFromClang(engineClangVersion);
3535
final Version clangSemVer = _parseVersionFromClang(clangVersion);
3636
if (engineClangSemVer > clangSemVer) {
@@ -44,21 +44,21 @@ Future<void> validateBitcode(BuildMode buildMode, TargetPlatform targetPlatform,
4444
}
4545
}
4646

47-
Version _parseVersionFromClang(String clangVersion) {
47+
Version _parseVersionFromClang(String? clangVersion) {
4848
final RegExp pattern = RegExp(r'Apple (LLVM|clang) version (\d+\.\d+\.\d+) ');
49-
void _invalid() {
49+
Never _invalid() {
5050
throwToolExit('Unable to parse Clang version from "$clangVersion". '
5151
'Expected a string like "Apple (LLVM|clang) #.#.# (clang-####.#.##.#)".');
5252
}
5353

5454
if (clangVersion == null || clangVersion.isEmpty) {
5555
_invalid();
5656
}
57-
final RegExpMatch match = pattern.firstMatch(clangVersion);
57+
final RegExpMatch? match = pattern.firstMatch(clangVersion);
5858
if (match == null || match.groupCount != 2) {
5959
_invalid();
6060
}
61-
final Version version = Version.parse(match.group(2));
61+
final Version? version = Version.parse(match.group(2));
6262
if (version == null) {
6363
_invalid();
6464
}

0 commit comments

Comments
 (0)