Declare locals final where not reassigned (flutter_tools) (#8570)
diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart
index 599521f..26b6c93 100644
--- a/packages/flutter_tools/lib/src/ios/mac.dart
+++ b/packages/flutter_tools/lib/src/ios/mac.dart
@@ -42,7 +42,7 @@
} else {
try {
printTrace('xcrun clang');
- ProcessResult result = processManager.runSync(<String>['/usr/bin/xcrun', 'clang']);
+ final ProcessResult result = processManager.runSync(<String>['/usr/bin/xcrun', 'clang']);
if (result.stdout != null && result.stdout.contains('license'))
_eulaSigned = false;
@@ -88,8 +88,8 @@
if (!xcodeVersionRegex.hasMatch(xcodeVersionText))
return false;
- String version = xcodeVersionRegex.firstMatch(xcodeVersionText).group(1);
- List<String> components = version.split('.');
+ final String version = xcodeVersionRegex.firstMatch(xcodeVersionText).group(1);
+ final List<String> components = version.split('.');
_xcodeMajorVersion = int.parse(components[0]);
_xcodeMinorVersion = components.length == 1 ? 0 : int.parse(components[1]);
@@ -115,7 +115,7 @@
bool buildForDevice,
bool codesign: true
}) async {
- String flutterProjectPath = fs.currentDirectory.path;
+ final String flutterProjectPath = fs.currentDirectory.path;
updateXcodeGeneratedProperties(flutterProjectPath, mode, target);
if (!_checkXcodeVersion())
@@ -126,7 +126,7 @@
await _addServicesToBundle(fs.directory(app.appDirectory));
- List<String> commands = <String>[
+ final List<String> commands = <String>[
'/usr/bin/env',
'xcrun',
'xcodebuild',
@@ -136,7 +136,7 @@
'ONLY_ACTIVE_ARCH=YES',
];
- List<FileSystemEntity> contents = fs.directory(app.appDirectory).listSync();
+ final List<FileSystemEntity> contents = fs.directory(app.appDirectory).listSync();
for (FileSystemEntity entity in contents) {
if (fs.path.extension(entity.path) == '.xcworkspace') {
commands.addAll(<String>[
@@ -164,7 +164,7 @@
);
}
- RunResult result = await runAsync(
+ final RunResult result = await runAsync(
commands,
workingDirectory: app.appDirectory,
allowReentrantFlutter: true
@@ -192,8 +192,8 @@
);
} else {
// Look for 'clean build/Release-iphoneos/Runner.app'.
- RegExp regexp = new RegExp(r' clean (\S*\.app)$', multiLine: true);
- Match match = regexp.firstMatch(result.stdout);
+ final RegExp regexp = new RegExp(r' clean (\S*\.app)$', multiLine: true);
+ final Match match = regexp.firstMatch(result.stdout);
String outputDir;
if (match != null)
outputDir = fs.path.join(app.appDirectory, match.group(1));
@@ -202,9 +202,9 @@
}
Future<Null> diagnoseXcodeBuildFailure(XcodeBuildResult result) async {
- File plistFile = fs.file('ios/Runner/Info.plist');
+ final File plistFile = fs.file('ios/Runner/Info.plist');
if (plistFile.existsSync()) {
- String plistContent = plistFile.readAsStringSync();
+ final String plistContent = plistFile.readAsStringSync();
if (plistContent.contains('com.yourcompany')) {
printError('');
printError('It appears that your application still contains the default signing identifier.');
@@ -232,7 +232,7 @@
assert(result.xcodeBuildExecution.appDirectory != null);
if (result.xcodeBuildExecution.buildForPhysicalDevice &&
result.xcodeBuildExecution.buildCommands.contains('build')) {
- RunResult checkBuildSettings = await runAsync(
+ final RunResult checkBuildSettings = await runAsync(
result.xcodeBuildExecution.buildCommands..add('-showBuildSettings'),
workingDirectory: result.xcodeBuildExecution.appDirectory,
allowReentrantFlutter: true
@@ -302,8 +302,8 @@
if (!platform.isMacOS)
return false;
try {
- String version = runCheckedSync(<String>['xcodebuild', '-version']);
- Match match = _xcodeVersionRegExp.firstMatch(version);
+ final String version = runCheckedSync(<String>['xcodebuild', '-version']);
+ final Match match = _xcodeVersionRegExp.firstMatch(version);
if (int.parse(match[1]) < 7) {
printError('Found "${match[0]}". $_xcodeRequirement');
return false;
@@ -316,7 +316,7 @@
}
Future<Null> _addServicesToBundle(Directory bundle) async {
- List<Map<String, String>> services = <Map<String, String>>[];
+ final List<Map<String, String>> services = <Map<String, String>>[];
printTrace("Trying to resolve native pub services.");
// Step 1: Parse the service configuration yaml files present in the service
@@ -325,12 +325,12 @@
printTrace("Found ${services.length} service definition(s).");
// Step 2: Copy framework dylibs to the correct spot for xcodebuild to pick up.
- Directory frameworksDirectory = fs.directory(fs.path.join(bundle.path, "Frameworks"));
+ final Directory frameworksDirectory = fs.directory(fs.path.join(bundle.path, "Frameworks"));
await _copyServiceFrameworks(services, frameworksDirectory);
// Step 3: Copy the service definitions manifest at the correct spot for
// xcodebuild to pick up.
- File manifestFile = fs.file(fs.path.join(bundle.path, "ServiceDefinitions.json"));
+ final File manifestFile = fs.file(fs.path.join(bundle.path, "ServiceDefinitions.json"));
_copyServiceDefinitionsManifest(services, manifestFile);
}
@@ -338,8 +338,8 @@
printTrace("Copying service frameworks to '${fs.path.absolute(frameworksDirectory.path)}'.");
frameworksDirectory.createSync(recursive: true);
for (Map<String, String> service in services) {
- String dylibPath = await getServiceFromUrl(service['ios-framework'], service['root'], service['name']);
- File dylib = fs.file(dylibPath);
+ final String dylibPath = await getServiceFromUrl(service['ios-framework'], service['root'], service['name']);
+ final File dylib = fs.file(dylibPath);
printTrace("Copying ${dylib.path} into bundle.");
if (!dylib.existsSync()) {
printError("The service dylib '${dylib.path}' does not exist.");
@@ -352,12 +352,12 @@
void _copyServiceDefinitionsManifest(List<Map<String, String>> services, File manifest) {
printTrace("Creating service definitions manifest at '${manifest.path}'");
- List<Map<String, String>> jsonServices = services.map((Map<String, String> service) => <String, String>{
+ final List<Map<String, String>> jsonServices = services.map((Map<String, String> service) => <String, String>{
'name': service['name'],
// Since we have already moved it to the Frameworks directory. Strip away
// the directory and basenames.
'framework': fs.path.basenameWithoutExtension(service['ios-framework'])
}).toList();
- Map<String, dynamic> json = <String, dynamic>{ 'services' : jsonServices };
+ final Map<String, dynamic> json = <String, dynamic>{ 'services' : jsonServices };
manifest.writeAsStringSync(JSON.encode(json), mode: FileMode.WRITE, flush: true);
}