enable lint prefer_final_in_for_each (#47724)
diff --git a/packages/flutter_tools/lib/src/android/android_builder.dart b/packages/flutter_tools/lib/src/android/android_builder.dart
index 17b5d5d..40ddbd6 100644
--- a/packages/flutter_tools/lib/src/android/android_builder.dart
+++ b/packages/flutter_tools/lib/src/android/android_builder.dart
@@ -68,7 +68,7 @@
// Module projects artifacts are located in `build/host`.
outputDirectory = outputDirectory.childDirectory('host');
}
- for (AndroidBuildInfo androidBuildInfo in androidBuildInfo) {
+ for (final AndroidBuildInfo androidBuildInfo in androidBuildInfo) {
await buildGradleAar(
project: project,
androidBuildInfo: androidBuildInfo,
diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart
index 3b8d6b5..384e3b0 100644
--- a/packages/flutter_tools/lib/src/android/android_device.dart
+++ b/packages/flutter_tools/lib/src/android/android_device.dart
@@ -732,7 +732,7 @@
Map<String, String> parseAdbDeviceProperties(String str) {
final Map<String, String> properties = <String, String>{};
final RegExp propertyExp = RegExp(r'\[(.*?)\]: \[(.*?)\]');
- for (Match match in propertyExp.allMatches(str)) {
+ for (final Match match in propertyExp.allMatches(str)) {
properties[match.group(1)] = match.group(2);
}
return properties;
@@ -932,7 +932,7 @@
return;
}
- for (String line in text.trim().split('\n')) {
+ for (final String line in text.trim().split('\n')) {
// Skip lines like: * daemon started successfully *
if (line.startsWith('* daemon ')) {
continue;
@@ -958,7 +958,7 @@
final Map<String, String> info = <String, String>{};
if (rest != null && rest.isNotEmpty) {
rest = rest.trim();
- for (String data in rest.split(' ')) {
+ for (final String data in rest.split(' ')) {
if (data.contains(':')) {
final List<String> fields = data.split(':');
info[fields[0]] = fields[1];
@@ -1165,7 +1165,7 @@
}
final List<String> lines = LineSplitter.split(stdout).toList();
- for (String line in lines) {
+ for (final String line in lines) {
if (!line.startsWith(device.id)) {
continue;
}
@@ -1260,7 +1260,7 @@
@override
Future<void> dispose() async {
- for (ForwardedPort port in forwardedPorts) {
+ for (final ForwardedPort port in forwardedPorts) {
await unforward(port);
}
}
diff --git a/packages/flutter_tools/lib/src/android/android_emulator.dart b/packages/flutter_tools/lib/src/android/android_emulator.dart
index 5a7a04e..b7c0557 100644
--- a/packages/flutter_tools/lib/src/android/android_emulator.dart
+++ b/packages/flutter_tools/lib/src/android/android_emulator.dart
@@ -85,7 +85,7 @@
/// Parse the given `emulator -list-avds` output in [text], and fill out the given list
/// of emulators by reading information from the relevant ini files.
void extractEmulatorAvdInfo(String text, List<AndroidEmulator> emulators) {
- for (String id in text.trim().split('\n').where((String l) => l != '')) {
+ for (final String id in text.trim().split('\n').where((String l) => l != '')) {
emulators.add(_loadEmulatorInfo(id));
}
}
@@ -125,7 +125,7 @@
// Split into name/value
.map<List<String>>((String l) => l.split('='));
- for (List<String> property in properties) {
+ for (final List<String> property in properties) {
results[property[0].trim()] = property[1].trim();
}
diff --git a/packages/flutter_tools/lib/src/android/android_sdk.dart b/packages/flutter_tools/lib/src/android/android_sdk.dart
index 7c4ab74..50fc605 100644
--- a/packages/flutter_tools/lib/src/android/android_sdk.dart
+++ b/packages/flutter_tools/lib/src/android/android_sdk.dart
@@ -215,7 +215,7 @@
.map<String>((String line) => line.trim())
.where((String line) => line.isNotEmpty);
final Map<String, String> properties = <String, String>{};
- for (String line in propertiesFileLines) {
+ for (final String line in propertiesFileLines) {
final List<String> parts = line.split(' = ');
if (parts.length == 2) {
properties[parts[0]] = parts[1];
diff --git a/packages/flutter_tools/lib/src/android/android_studio.dart b/packages/flutter_tools/lib/src/android/android_studio.dart
index 32014e2..f7ebfb4 100644
--- a/packages/flutter_tools/lib/src/android/android_studio.dart
+++ b/packages/flutter_tools/lib/src/android/android_studio.dart
@@ -183,7 +183,7 @@
.directory(path)
.listSync(followLinks: false)
.whereType<Directory>();
- for (Directory directory in directories) {
+ for (final Directory directory in directories) {
final String name = directory.basename;
// An exact match, or something like 'Android Studio 3.0 Preview.app'.
if (name.startsWith('Android Studio') && name.endsWith('.app')) {
@@ -236,7 +236,7 @@
// Read all $HOME/.AndroidStudio*/system/.home files. There may be several
// pointing to the same installation, so we grab only the latest one.
if (homeDirPath != null && globals.fs.directory(homeDirPath).existsSync()) {
- for (FileSystemEntity entity in globals.fs.directory(homeDirPath).listSync(followLinks: false)) {
+ for (final FileSystemEntity entity in globals.fs.directory(homeDirPath).listSync(followLinks: false)) {
if (entity is Directory && entity.basename.startsWith('.AndroidStudio')) {
final AndroidStudio studio = AndroidStudio.fromHomeDot(entity);
if (studio != null && !_hasStudioAt(studio.directory, newerThan: studio.version)) {
diff --git a/packages/flutter_tools/lib/src/android/gradle.dart b/packages/flutter_tools/lib/src/android/gradle.dart
index 676599a..82364a1 100644
--- a/packages/flutter_tools/lib/src/android/gradle.dart
+++ b/packages/flutter_tools/lib/src/android/gradle.dart
@@ -116,7 +116,7 @@
if (!appGradle.existsSync()) {
return false;
}
- for (String line in appGradle.readAsLinesSync()) {
+ for (final String line in appGradle.readAsLinesSync()) {
if (line.contains(RegExp(r'apply from: .*/flutter.gradle')) ||
line.contains("def flutterPluginVersion = 'managed'")) {
return true;
@@ -184,7 +184,7 @@
existingVariants.add(settingsAarContent);
bool exactMatch = false;
- for (String fileContentVariant in existingVariants) {
+ for (final String fileContentVariant in existingVariants) {
if (currentFileContent.trim() == fileContentVariant.trim()) {
exactMatch = true;
break;
@@ -465,7 +465,7 @@
final File apkShaFile = apkDirectory.childFile('app.apk.sha1');
apkShaFile.writeAsStringSync(_calculateSha(apkFiles.first));
- for (File apkFile in apkFiles) {
+ for (final File apkFile in apkFiles) {
final String appSize = (buildInfo.mode == BuildMode.debug)
? '' // Don't display the size when building a debug variant.
: ' (${getSizeAsMB(apkFile.lengthSync())})';
@@ -618,7 +618,7 @@
dependencies {''');
- for (String buildMode in buildModes) {
+ for (final String buildMode in buildModes) {
globals.printStatus('''
${buildMode}Implementation '$androidPackage:flutter_$buildMode:$buildNumber''');
}
@@ -647,7 +647,7 @@
String _hex(List<int> bytes) {
final StringBuffer result = StringBuffer();
- for (int part in bytes) {
+ for (final int part in bytes) {
result.write('${part < 16 ? '0' : ''}${part.toRadixString(16)}');
}
return result.toString();
@@ -707,7 +707,7 @@
return;
}
final List<String> plugins = flutterPluginFile.readAsStringSync().split('\n');
- for (String plugin in plugins) {
+ for (final String plugin in plugins) {
final List<String> pluginParts = plugin.split('=');
if (pluginParts.length != 2) {
continue;
@@ -882,7 +882,7 @@
}
final Iterable<xml.XmlElement> project = document.findElements('project');
assert(project.isNotEmpty);
- for (xml.XmlElement versionElement in document.findAllElements('version')) {
+ for (final xml.XmlElement versionElement in document.findAllElements('version')) {
if (versionElement.parent == project.first) {
return versionElement.text;
}
@@ -919,7 +919,7 @@
'flutter_embedding_$buildMode.pom',
)
);
- for (String artifact in const <String>['pom', 'jar']) {
+ for (final String artifact in const <String>['pom', 'jar']) {
// The Android embedding artifacts.
_createSymlink(
globals.fs.path.join(
diff --git a/packages/flutter_tools/lib/src/android/gradle_errors.dart b/packages/flutter_tools/lib/src/android/gradle_errors.dart
index be2c00a..9d5e63b 100644
--- a/packages/flutter_tools/lib/src/android/gradle_errors.dart
+++ b/packages/flutter_tools/lib/src/android/gradle_errors.dart
@@ -283,7 +283,7 @@
);
// Extract build types and product flavors.
final Set<String> variants = <String>{};
- for (String task in tasksRunResult.stdout.split('\n')) {
+ for (final String task in tasksRunResult.stdout.split('\n')) {
final Match match = _assembleTaskPattern.matchAsPrefix(task);
if (match != null) {
final String variant = match.group(1).toLowerCase();