Declare locals final where not reassigned (flutter_tools) (#8570)
diff --git a/packages/flutter_tools/lib/src/ios/devices.dart b/packages/flutter_tools/lib/src/ios/devices.dart
index 343956d..9075daf 100644
--- a/packages/flutter_tools/lib/src/ios/devices.dart
+++ b/packages/flutter_tools/lib/src/ios/devices.dart
@@ -97,18 +97,18 @@
if (!doctor.iosWorkflow.hasIDeviceId)
return <IOSDevice>[];
- List<IOSDevice> devices = <IOSDevice>[];
+ final List<IOSDevice> devices = <IOSDevice>[];
for (String id in _getAttachedDeviceIDs(mockIOS)) {
- String name = IOSDevice._getDeviceInfo(id, 'DeviceName', mockIOS);
+ final String name = IOSDevice._getDeviceInfo(id, 'DeviceName', mockIOS);
devices.add(new IOSDevice(id, name: name));
}
return devices;
}
static Iterable<String> _getAttachedDeviceIDs([IOSDevice mockIOS]) {
- String listerPath = (mockIOS != null) ? mockIOS.listerPath : _checkForCommand('idevice_id');
+ final String listerPath = (mockIOS != null) ? mockIOS.listerPath : _checkForCommand('idevice_id');
try {
- String output = runSync(<String>[listerPath, '-l']);
+ final String output = runSync(<String>[listerPath, '-l']);
return output.trim().split('\n').where((String s) => s != null && s.isNotEmpty);
} catch (e) {
return <String>[];
@@ -116,7 +116,7 @@
}
static String _getDeviceInfo(String deviceID, String infoKey, [IOSDevice mockIOS]) {
- String informerPath = (mockIOS != null)
+ final String informerPath = (mockIOS != null)
? mockIOS.informerPath
: _checkForCommand('ideviceinfo');
return runSync(<String>[informerPath, '-k', infoKey, '-u', deviceID]).trim();
@@ -142,7 +142,7 @@
@override
bool isAppInstalled(ApplicationPackage app) {
try {
- String apps = runCheckedSync(<String>[installerPath, '--list-apps']);
+ final String apps = runCheckedSync(<String>[installerPath, '--list-apps']);
if (new RegExp(app.id, multiLine: true).hasMatch(apps)) {
return true;
}
@@ -157,8 +157,8 @@
@override
bool installApp(ApplicationPackage app) {
- IOSApp iosApp = app;
- Directory bundle = fs.directory(iosApp.deviceBundlePath);
+ final IOSApp iosApp = app;
+ final Directory bundle = fs.directory(iosApp.deviceBundlePath);
if (!bundle.existsSync()) {
printError("Could not find application bundle at ${bundle.path}; have you run 'flutter build ios'?");
return false;
@@ -203,7 +203,7 @@
printTrace('Building ${app.name} for $id');
// Step 1: Build the precompiled/DBC application if necessary.
- XcodeBuildResult buildResult = await buildXcodeProject(app: app, mode: mode, target: mainPath, buildForDevice: true);
+ final XcodeBuildResult buildResult = await buildXcodeProject(app: app, mode: mode, target: mainPath, buildForDevice: true);
if (!buildResult.success) {
printError('Could not build the precompiled application for the device.');
await diagnoseXcodeBuildFailure(buildResult);
@@ -216,15 +216,15 @@
}
// Step 2: Check that the application exists at the specified path.
- IOSApp iosApp = app;
- Directory bundle = fs.directory(iosApp.deviceBundlePath);
+ final IOSApp iosApp = app;
+ final Directory bundle = fs.directory(iosApp.deviceBundlePath);
if (!bundle.existsSync()) {
printError('Could not find the built application bundle at ${bundle.path}.');
return new LaunchResult.failed();
}
// Step 3: Attempt to install the application on the device.
- List<String> launchArguments = <String>["--enable-dart-profiling"];
+ final List<String> launchArguments = <String>["--enable-dart-profiling"];
if (debuggingOptions.startPaused)
launchArguments.add("--start-paused");
@@ -240,7 +240,7 @@
if (platformArgs['trace-startup'] ?? false)
launchArguments.add('--trace-startup');
- List<String> launchCommand = <String>[
+ final List<String> launchCommand = <String>[
'/usr/bin/env',
'ios-deploy',
'--id',
@@ -271,12 +271,12 @@
// TODO(danrubel): The Android device class does something similar to this code below.
// The various Device subclasses should be refactored and common code moved into the superclass.
- ProtocolDiscovery observatoryDiscovery = new ProtocolDiscovery.observatory(
+ final ProtocolDiscovery observatoryDiscovery = new ProtocolDiscovery.observatory(
getLogReader(app: app), portForwarder: portForwarder, hostPort: debuggingOptions.observatoryPort);
- ProtocolDiscovery diagnosticDiscovery = new ProtocolDiscovery.diagnosticService(
+ final ProtocolDiscovery diagnosticDiscovery = new ProtocolDiscovery.diagnosticService(
getLogReader(app: app), portForwarder: portForwarder, hostPort: debuggingOptions.diagnosticPort);
- Future<Uri> forwardObsUri = observatoryDiscovery.nextUri();
+ final Future<Uri> forwardObsUri = observatoryDiscovery.nextUri();
Future<Uri> forwardDiagUri;
if (debuggingOptions.buildMode == BuildMode.debug) {
forwardDiagUri = diagnosticDiscovery.nextUri();
@@ -284,9 +284,9 @@
forwardDiagUri = new Future<Uri>.value(null);
}
- Future<int> launch = runCommandAndStreamOutput(launchCommand, trace: true);
+ final Future<int> launch = runCommandAndStreamOutput(launchCommand, trace: true);
- List<Uri> uris = await launch.then<List<Uri>>((int result) async {
+ final List<Uri> uris = await launch.then<List<Uri>>((int result) async {
installationResult = result;
if (result != 0) {
@@ -392,7 +392,7 @@
//
// iOS 9 format: Runner[297] <Notice>:
// iOS 10 format: Runner(libsystem_asl.dylib)[297] <Notice>:
- String appName = app == null ? '' : app.name.replaceAll('.app', '');
+ final String appName = app == null ? '' : app.name.replaceAll('.app', '');
_lineRegex = new RegExp(appName + r'(\(.*\))?\[[\d]+\] <[A-Za-z]+>: ');
}
@@ -420,7 +420,7 @@
}
void _onLine(String line) {
- Match match = _lineRegex.firstMatch(line);
+ final Match match = _lineRegex.firstMatch(line);
if (match != null) {
// Only display the log line after the initial device and executable information.
@@ -451,14 +451,14 @@
}
// Usage: iproxy LOCAL_TCP_PORT DEVICE_TCP_PORT UDID
- Process process = await runCommand(<String>[
+ final Process process = await runCommand(<String>[
device.iproxyPath,
hostPort.toString(),
devicePort.toString(),
device.id,
]);
- ForwardedPort forwardedPort = new ForwardedPort.withContext(hostPort,
+ final ForwardedPort forwardedPort = new ForwardedPort.withContext(hostPort,
devicePort, process);
printTrace("Forwarded port $forwardedPort");
@@ -477,7 +477,7 @@
printTrace("Unforwarding port $forwardedPort");
- Process process = forwardedPort.context;
+ final Process process = forwardedPort.context;
if (process != null) {
processManager.killPid(process.pid);
diff --git a/packages/flutter_tools/lib/src/ios/ios_workflow.dart b/packages/flutter_tools/lib/src/ios/ios_workflow.dart
index 6a672f8..3154fab 100644
--- a/packages/flutter_tools/lib/src/ios/ios_workflow.dart
+++ b/packages/flutter_tools/lib/src/ios/ios_workflow.dart
@@ -46,7 +46,7 @@
if (!hasIosDeploy)
return false;
try {
- Version version = new Version.parse(iosDeployVersionText);
+ final Version version = new Version.parse(iosDeployVersionText);
return version >= new Version.parse(iosDeployMinimumVersion);
} on FormatException catch (_) {
return false;
@@ -55,7 +55,7 @@
@override
Future<ValidationResult> validate() async {
- List<ValidationMessage> messages = <ValidationMessage>[];
+ final List<ValidationMessage> messages = <ValidationMessage>[];
ValidationType xcodeStatus = ValidationType.missing;
ValidationType pythonStatus = ValidationType.missing;
ValidationType brewStatus = ValidationType.missing;
@@ -143,7 +143,7 @@
} else {
// Check for compatibility between libimobiledevice and Xcode.
// TODO(cbracken) remove this check once libimobiledevice > 1.2.0 is released.
- ProcessResult result = (await runAsync(<String>['idevice_id', '-l'])).processResult;
+ final ProcessResult result = (await runAsync(<String>['idevice_id', '-l'])).processResult;
if (result.exitCode == 0 && result.stdout.isNotEmpty && !exitsHappy(<String>['ideviceName'])) {
brewStatus = ValidationType.partial;
messages.add(new ValidationMessage.error(
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);
}
diff --git a/packages/flutter_tools/lib/src/ios/plist_utils.dart b/packages/flutter_tools/lib/src/ios/plist_utils.dart
index 105c18c..6d727d4 100644
--- a/packages/flutter_tools/lib/src/ios/plist_utils.dart
+++ b/packages/flutter_tools/lib/src/ios/plist_utils.dart
@@ -19,10 +19,10 @@
if (!fs.isFileSync(plistFilePath))
return null;
- String normalizedPlistPath = fs.path.withoutExtension(fs.path.absolute(plistFilePath));
+ final String normalizedPlistPath = fs.path.withoutExtension(fs.path.absolute(plistFilePath));
try {
- String value = runCheckedSync(<String>[
+ final String value = runCheckedSync(<String>[
'/usr/bin/defaults', 'read', normalizedPlistPath, key
]);
return value.isEmpty ? null : value;
diff --git a/packages/flutter_tools/lib/src/ios/simulators.dart b/packages/flutter_tools/lib/src/ios/simulators.dart
index 6a82aa9..71b46c4 100644
--- a/packages/flutter_tools/lib/src/ios/simulators.dart
+++ b/packages/flutter_tools/lib/src/ios/simulators.dart
@@ -61,7 +61,7 @@
return true;
if (deviceName == null) {
- SimDevice testDevice = _createTestDevice();
+ final SimDevice testDevice = _createTestDevice();
if (testDevice == null) {
return false;
}
@@ -72,7 +72,7 @@
// "template" is but the built-in 'Blank' seems to work. -l causes xcrun to
// quit after a time limit without killing the simulator. We quit after
// 1 second.
- List<String> args = <String>[_xcrunPath, 'instruments', '-w', deviceName, '-t', 'Blank', '-l', '1'];
+ final List<String> args = <String>[_xcrunPath, 'instruments', '-w', deviceName, '-t', 'Blank', '-l', '1'];
printTrace(args.join(' '));
runDetached(args);
printStatus('Waiting for iOS Simulator to boot...');
@@ -98,11 +98,11 @@
}
SimDevice _createTestDevice() {
- SimDeviceType deviceType = _findSuitableDeviceType();
+ final SimDeviceType deviceType = _findSuitableDeviceType();
if (deviceType == null)
return null;
- String runtime = _findSuitableRuntime();
+ final String runtime = _findSuitableRuntime();
if (runtime == null)
return null;
@@ -112,8 +112,8 @@
.forEach(_deleteDevice);
// Create new device
- String deviceName = '${deviceType.name} $_kFlutterTestDeviceSuffix';
- List<String> args = <String>[_xcrunPath, 'simctl', 'create', deviceName, deviceType.identifier, runtime];
+ final String deviceName = '${deviceType.name} $_kFlutterTestDeviceSuffix';
+ final List<String> args = <String>[_xcrunPath, 'simctl', 'create', deviceName, deviceType.identifier, runtime];
printTrace(args.join(' '));
runCheckedSync(args);
@@ -121,8 +121,8 @@
}
SimDeviceType _findSuitableDeviceType() {
- List<Map<String, dynamic>> allTypes = _list(SimControlListSection.devicetypes);
- List<Map<String, dynamic>> usableTypes = allTypes
+ final List<Map<String, dynamic>> allTypes = _list(SimControlListSection.devicetypes);
+ final List<Map<String, dynamic>> usableTypes = allTypes
.where((Map<String, dynamic> info) => info['name'].startsWith('iPhone'))
.toList()
..sort((Map<String, dynamic> r1, Map<String, dynamic> r2) => -compareIphoneVersions(r1['identifier'], r2['identifier']));
@@ -141,8 +141,8 @@
}
String _findSuitableRuntime() {
- List<Map<String, dynamic>> allRuntimes = _list(SimControlListSection.runtimes);
- List<Map<String, dynamic>> usableRuntimes = allRuntimes
+ final List<Map<String, dynamic>> allRuntimes = _list(SimControlListSection.runtimes);
+ final List<Map<String, dynamic>> usableRuntimes = allRuntimes
.where((Map<String, dynamic> info) => info['name'].startsWith('iOS'))
.toList()
..sort((Map<String, dynamic> r1, Map<String, dynamic> r2) => -compareIosVersions(r1['version'], r2['version']));
@@ -159,7 +159,7 @@
void _deleteDevice(SimDevice device) {
try {
- List<String> args = <String>[_xcrunPath, 'simctl', 'delete', device.name];
+ final List<String> args = <String>[_xcrunPath, 'simctl', 'delete', device.name];
printTrace(args.join(' '));
runCheckedSync(args);
} catch(e) {
@@ -190,9 +190,9 @@
// },
// "pairs": { ... },
- List<String> command = <String>[_xcrunPath, 'simctl', 'list', '--json', section.name];
+ final List<String> command = <String>[_xcrunPath, 'simctl', 'list', '--json', section.name];
printTrace(command.join(' '));
- ProcessResult results = processManager.runSync(command);
+ final ProcessResult results = processManager.runSync(command);
if (results.exitCode != 0) {
printError('Error executing simctl: ${results.exitCode}\n${results.stderr}');
return <String, Map<String, dynamic>>{};
@@ -203,12 +203,12 @@
/// Returns a list of all available devices, both potential and connected.
List<SimDevice> getDevices() {
- List<SimDevice> devices = <SimDevice>[];
+ final List<SimDevice> devices = <SimDevice>[];
- Map<String, dynamic> devicesSection = _list(SimControlListSection.devices);
+ final Map<String, dynamic> devicesSection = _list(SimControlListSection.devices);
for (String deviceCategory in devicesSection.keys) {
- List<Map<String, String>> devicesData = devicesSection[deviceCategory];
+ final List<Map<String, String>> devicesData = devicesSection[deviceCategory];
for (Map<String, String> data in devicesData) {
devices.add(new SimDevice(deviceCategory, data));
@@ -244,7 +244,7 @@
}
void launch(String deviceId, String appIdentifier, [List<String> launchArgs]) {
- List<String> args = <String>[_xcrunPath, 'simctl', 'launch', deviceId, appIdentifier];
+ final List<String> args = <String>[_xcrunPath, 'simctl', 'launch', deviceId, appIdentifier];
if (launchArgs != null)
args.addAll(launchArgs);
runCheckedSync(args);
@@ -329,7 +329,7 @@
}
String _getSimulatorAppHomeDirectory(ApplicationPackage app) {
- String simulatorPath = _getSimulatorPath();
+ final String simulatorPath = _getSimulatorPath();
if (simulatorPath == null)
return null;
return fs.path.join(simulatorPath, 'data');
@@ -346,7 +346,7 @@
@override
bool installApp(ApplicationPackage app) {
try {
- IOSApp iosApp = app;
+ final IOSApp iosApp = app;
SimControl.instance.install(id, iosApp.simulatorBundlePath);
return true;
} catch (e) {
@@ -374,7 +374,7 @@
// Step 1: Check if the device is part of a blacklisted category.
// We do not support WatchOS or tvOS devices.
- RegExp blacklist = new RegExp(r'Apple (TV|Watch)', caseSensitive: false);
+ final RegExp blacklist = new RegExp(r'Apple (TV|Watch)', caseSensitive: false);
if (blacklist.hasMatch(name)) {
_supportMessage = 'Flutter does not support Apple TV or Apple Watch. Select an iPhone 5s or above.';
return false;
@@ -386,14 +386,14 @@
// runner on the simulator is completely different).
// Check for unsupported iPads.
- Match iPadMatch = new RegExp(r'iPad (2|Retina)', caseSensitive: false).firstMatch(name);
+ final Match iPadMatch = new RegExp(r'iPad (2|Retina)', caseSensitive: false).firstMatch(name);
if (iPadMatch != null) {
_supportMessage = 'Flutter does not yet support iPad 2 or iPad Retina. Select an iPad Air or above.';
return false;
}
// Check for unsupported iPhones.
- Match iPhoneMatch = new RegExp(r'iPhone [0-5]').firstMatch(name);
+ final Match iPhoneMatch = new RegExp(r'iPhone [0-5]').firstMatch(name);
if (iPhoneMatch != null) {
if (name == 'iPhone 5s')
return true;
@@ -441,7 +441,7 @@
}
// Prepare launch arguments.
- List<String> args = <String>['--enable-dart-profiling'];
+ final List<String> args = <String>['--enable-dart-profiling'];
if (!prebuiltApplication) {
args.addAll(<String>[
@@ -457,9 +457,9 @@
if (debuggingOptions.startPaused)
args.add('--start-paused');
- int observatoryPort = await debuggingOptions.findBestObservatoryPort();
+ final int observatoryPort = await debuggingOptions.findBestObservatoryPort();
args.add('--observatory-port=$observatoryPort');
- int diagnosticPort = await debuggingOptions.findBestDiagnosticPort();
+ final int diagnosticPort = await debuggingOptions.findBestDiagnosticPort();
args.add('--diagnostic-port=$diagnosticPort');
}
@@ -484,7 +484,7 @@
printTrace('Waiting for observatory port to be available...');
try {
- Uri deviceUri = await observatoryDiscovery.nextUri();
+ final Uri deviceUri = await observatoryDiscovery.nextUri();
return new LaunchResult.succeeded(observatoryUri: deviceUri);
} catch (error) {
printError('Error waiting for a debug connection: $error');
@@ -495,9 +495,9 @@
}
bool _applicationIsInstalledAndRunning(ApplicationPackage app) {
- bool isInstalled = isAppInstalled(app);
+ final bool isInstalled = isAppInstalled(app);
- bool isRunning = exitsHappy(<String>[
+ final bool isRunning = exitsHappy(<String>[
'/usr/bin/killall',
'Runner',
]);
@@ -515,14 +515,14 @@
Future<Null> _buildAndInstallApplicationBundle(ApplicationPackage app) async {
// Step 1: Build the Xcode project.
// The build mode for the simulator is always debug.
- XcodeBuildResult buildResult = await buildXcodeProject(app: app, mode: BuildMode.debug, buildForDevice: false);
+ final XcodeBuildResult buildResult = await buildXcodeProject(app: app, mode: BuildMode.debug, buildForDevice: false);
if (!buildResult.success)
throwToolExit('Could not build the application for the simulator.');
// Step 2: Assert that the Xcode project was successfully built.
- IOSApp iosApp = app;
- Directory bundle = fs.directory(iosApp.simulatorBundlePath);
- bool bundleExists = bundle.existsSync();
+ final IOSApp iosApp = app;
+ final Directory bundle = fs.directory(iosApp.simulatorBundlePath);
+ final bool bundleExists = bundle.existsSync();
if (!bundleExists)
throwToolExit('Could not find the built application bundle at ${bundle.path}.');
@@ -542,7 +542,7 @@
Future<bool> pushFile(
ApplicationPackage app, String localFile, String targetFile) async {
if (p.platform.isMacOS) {
- String simulatorHomeDirectory = _getSimulatorAppHomeDirectory(app);
+ final String simulatorHomeDirectory = _getSimulatorAppHomeDirectory(app);
runCheckedSync(<String>['cp', localFile, fs.path.join(simulatorHomeDirectory, targetFile)]);
return true;
}
@@ -575,16 +575,16 @@
@override
void clearLogs() {
- File logFile = fs.file(logFilePath);
+ final File logFile = fs.file(logFilePath);
if (logFile.existsSync()) {
- RandomAccessFile randomFile = logFile.openSync(mode: FileMode.WRITE);
+ final RandomAccessFile randomFile = logFile.openSync(mode: FileMode.WRITE);
randomFile.truncateSync(0);
randomFile.closeSync();
}
}
void ensureLogsExists() {
- File logFile = fs.file(logFilePath);
+ final File logFile = fs.file(logFilePath);
if (!logFile.existsSync())
logFile.writeAsBytesSync(<int>[]);
}
@@ -667,10 +667,10 @@
];
String _filterDeviceLine(String string) {
- Match match = _mapRegex.matchAsPrefix(string);
+ final Match match = _mapRegex.matchAsPrefix(string);
if (match != null) {
- String category = match.group(1);
- String content = match.group(2);
+ final String category = match.group(1);
+ final String content = match.group(2);
// Filter out some messages that clearly aren't related to Flutter.
if (string.contains(': could not find icon for representation -> com.apple.'))
@@ -720,7 +720,7 @@
void _onDeviceLine(String line) {
printTrace('[DEVICE LOG] $line');
- Match multi = _lastMessageMultipleRegex.matchAsPrefix(line);
+ final Match multi = _lastMessageMultipleRegex.matchAsPrefix(line);
if (multi != null) {
if (_lastLine != null) {
@@ -737,7 +737,7 @@
}
String _filterSystemLog(String string) {
- Match match = _mapRegex.matchAsPrefix(string);
+ final Match match = _mapRegex.matchAsPrefix(string);
return match == null ? string : '${match.group(1)}: ${match.group(2)}';
}
@@ -746,7 +746,7 @@
if (!_flutterRunnerRegex.hasMatch(line))
return;
- String filteredLine = _filterSystemLog(line);
+ final String filteredLine = _filterSystemLog(line);
if (filteredLine == null)
return;
@@ -760,13 +760,13 @@
}
int compareIosVersions(String v1, String v2) {
- List<int> v1Fragments = v1.split('.').map(int.parse).toList();
- List<int> v2Fragments = v2.split('.').map(int.parse).toList();
+ final List<int> v1Fragments = v1.split('.').map(int.parse).toList();
+ final List<int> v2Fragments = v2.split('.').map(int.parse).toList();
int i = 0;
while(i < v1Fragments.length && i < v2Fragments.length) {
- int v1Fragment = v1Fragments[i];
- int v2Fragment = v2Fragments[i];
+ final int v1Fragment = v1Fragments[i];
+ final int v2Fragment = v2Fragments[i];
if (v1Fragment != v2Fragment)
return v1Fragment.compareTo(v2Fragment);
i++;
@@ -786,11 +786,11 @@
new RegExp(r'com.apple.CoreSimulator.SimDeviceType.iPhone-(\d+)(.*)');
int compareIphoneVersions(String id1, String id2) {
- Match m1 = _iosDeviceTypePattern.firstMatch(id1);
- Match m2 = _iosDeviceTypePattern.firstMatch(id2);
+ final Match m1 = _iosDeviceTypePattern.firstMatch(id1);
+ final Match m2 = _iosDeviceTypePattern.firstMatch(id2);
- int v1 = int.parse(m1[1]);
- int v2 = int.parse(m2[1]);
+ final int v1 = int.parse(m1[1]);
+ final int v2 = int.parse(m2[1]);
if (v1 != v2)
return v1.compareTo(v2);
@@ -798,8 +798,8 @@
// Sorted in the least preferred first order.
const List<String> qualifiers = const <String>['-Plus', '', 's-Plus', 's'];
- int q1 = qualifiers.indexOf(m1[2]);
- int q2 = qualifiers.indexOf(m2[2]);
+ final int q1 = qualifiers.indexOf(m1[2]);
+ final int q2 = qualifiers.indexOf(m2[2]);
return q1.compareTo(q2);
}
diff --git a/packages/flutter_tools/lib/src/ios/xcodeproj.dart b/packages/flutter_tools/lib/src/ios/xcodeproj.dart
index 9cd5087..c32ab15 100644
--- a/packages/flutter_tools/lib/src/ios/xcodeproj.dart
+++ b/packages/flutter_tools/lib/src/ios/xcodeproj.dart
@@ -13,11 +13,11 @@
final RegExp _varExpr = new RegExp(r'\$\((.*)\)');
void updateXcodeGeneratedProperties(String projectPath, BuildMode mode, String target) {
- StringBuffer localsBuffer = new StringBuffer();
+ final StringBuffer localsBuffer = new StringBuffer();
localsBuffer.writeln('// This is a generated file; do not edit or check into version control.');
- String flutterRoot = fs.path.normalize(Cache.flutterRoot);
+ final String flutterRoot = fs.path.normalize(Cache.flutterRoot);
localsBuffer.writeln('FLUTTER_ROOT=$flutterRoot');
// This holds because requiresProjectRoot is true for this command
@@ -34,27 +34,27 @@
localsBuffer.writeln('SYMROOT=\${SOURCE_ROOT}/../${getIosBuildDirectory()}');
- String flutterFrameworkDir = fs.path.normalize(fs.path.dirname(artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, mode)));
+ final String flutterFrameworkDir = fs.path.normalize(fs.path.dirname(artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, mode)));
localsBuffer.writeln('FLUTTER_FRAMEWORK_DIR=$flutterFrameworkDir');
if (artifacts is LocalEngineArtifacts) {
- LocalEngineArtifacts localEngineArtifacts = artifacts;
+ final LocalEngineArtifacts localEngineArtifacts = artifacts;
localsBuffer.writeln('LOCAL_ENGINE=${localEngineArtifacts.engineOutPath}');
}
- File localsFile = fs.file(fs.path.join(projectPath, 'ios', 'Flutter', 'Generated.xcconfig'));
+ final File localsFile = fs.file(fs.path.join(projectPath, 'ios', 'Flutter', 'Generated.xcconfig'));
localsFile.createSync(recursive: true);
localsFile.writeAsStringSync(localsBuffer.toString());
}
Map<String, String> getXcodeBuildSettings(String xcodeProjPath, String target) {
- String absProjPath = fs.path.absolute(xcodeProjPath);
- String out = runCheckedSync(<String>[
+ final String absProjPath = fs.path.absolute(xcodeProjPath);
+ final String out = runCheckedSync(<String>[
'/usr/bin/xcodebuild', '-project', absProjPath, '-target', target, '-showBuildSettings'
]);
- Map<String, String> settings = <String, String>{};
+ final Map<String, String> settings = <String, String>{};
for (String line in out.split('\n').where(_settingExpr.hasMatch)) {
- Match match = _settingExpr.firstMatch(line);
+ final Match match = _settingExpr.firstMatch(line);
settings[match[1]] = match[2];
}
return settings;
@@ -64,10 +64,10 @@
/// Substitutes variables in [str] with their values from the specified Xcode
/// project and target.
String substituteXcodeVariables(String str, String xcodeProjPath, String target) {
- Iterable<Match> matches = _varExpr.allMatches(str);
+ final Iterable<Match> matches = _varExpr.allMatches(str);
if (matches.isEmpty)
return str;
- Map<String, String> settings = getXcodeBuildSettings(xcodeProjPath, target);
+ final Map<String, String> settings = getXcodeBuildSettings(xcodeProjPath, target);
return str.replaceAllMapped(_varExpr, (Match m) => settings[m[1]] ?? m[0]);
}