enable lint prefer_final_in_for_each (#47724)
diff --git a/dev/benchmarks/macrobenchmarks/lib/src/cubic_bezier.dart b/dev/benchmarks/macrobenchmarks/lib/src/cubic_bezier.dart
index 766c697..90ca20a 100644
--- a/dev/benchmarks/macrobenchmarks/lib/src/cubic_bezier.dart
+++ b/dev/benchmarks/macrobenchmarks/lib/src/cubic_bezier.dart
@@ -146,7 +146,7 @@
path.moveTo(100.0, 97.0);
- for (Point p in pointList[0]) {
+ for (final Point p in pointList[0]) {
path.lineTo(p.x, p.y);
}
@@ -167,7 +167,7 @@
bezier2Path.moveTo(0.0, 70.55);
- for (Point p in pointList[1]) {
+ for (final Point p in pointList[1]) {
bezier2Path.lineTo(p.x, p.y);
}
@@ -188,7 +188,7 @@
bezier3Path.moveTo(0.0, 69.48);
- for (Point p in pointList[2]) {
+ for (final Point p in pointList[2]) {
bezier3Path.lineTo(p.x, p.y);
}
@@ -210,7 +210,7 @@
bezier4Path.moveTo(0.0, 69.48);
- for (Point p in pointList[3]) {
+ for (final Point p in pointList[3]) {
bezier4Path.lineTo(p.x, p.y);
}
@@ -221,7 +221,7 @@
}
List<PathDetail> _playReversed() {
- for (List<Point> list in pointList) {
+ for (final List<Point> list in pointList) {
if (list.isNotEmpty) {
list.removeLast();
}
@@ -232,7 +232,7 @@
path.moveTo(100.0, 97.0);
- for (Point point in points) {
+ for (final Point point in points) {
path.lineTo(point.x, point.y);
}
@@ -240,14 +240,14 @@
bezier2Path.moveTo(0.0, 70.55);
- for (Point p in pointList[1]) {
+ for (final Point p in pointList[1]) {
bezier2Path.lineTo(p.x, p.y);
}
final Path bezier3Path = Path();
bezier3Path.moveTo(0.0, 69.48);
- for (Point p in pointList[2]) {
+ for (final Point p in pointList[2]) {
bezier3Path.lineTo(p.x, p.y);
}
@@ -255,7 +255,7 @@
bezier4Path.moveTo(0.0, 69.48);
- for (Point p in pointList[3]) {
+ for (final Point p in pointList[3]) {
bezier4Path.lineTo(p.x, p.y);
}
@@ -287,7 +287,7 @@
void playAnimation() {
isPlaying = true;
isReversed = false;
- for (List<Point> list in pointList) {
+ for (final List<Point> list in pointList) {
list.clear();
}
controller.reset();
@@ -297,7 +297,7 @@
void stopAnimation() {
isPlaying = false;
controller.stop();
- for (List<Point> list in pointList) {
+ for (final List<Point> list in pointList) {
list.clear();
}
}
diff --git a/dev/benchmarks/microbenchmarks/lib/common.dart b/dev/benchmarks/microbenchmarks/lib/common.dart
index 0fa0e8a..62a08fd 100644
--- a/dev/benchmarks/microbenchmarks/lib/common.dart
+++ b/dev/benchmarks/microbenchmarks/lib/common.dart
@@ -51,7 +51,7 @@
String _printJson() {
final Map<String, double> results = <String, double>{};
- for (_BenchmarkResult result in _results) {
+ for (final _BenchmarkResult result in _results) {
results[result.name] = result.value;
}
return json.encode(results);
@@ -59,7 +59,7 @@
String _printPlainText() {
final StringBuffer buf = StringBuffer();
- for (_BenchmarkResult result in _results) {
+ for (final _BenchmarkResult result in _results) {
buf.writeln('${result.description}: ${result.value.toStringAsFixed(1)} ${result.unit}');
}
return buf.toString();
diff --git a/dev/benchmarks/microbenchmarks/lib/gestures/velocity_tracker_bench.dart b/dev/benchmarks/microbenchmarks/lib/gestures/velocity_tracker_bench.dart
index 93a4c2f..cfd1546 100644
--- a/dev/benchmarks/microbenchmarks/lib/gestures/velocity_tracker_bench.dart
+++ b/dev/benchmarks/microbenchmarks/lib/gestures/velocity_tracker_bench.dart
@@ -16,7 +16,7 @@
print('Velocity tracker benchmark...');
watch.start();
for (int i = 0; i < _kNumIters; i += 1) {
- for (PointerEvent event in velocityEventData) {
+ for (final PointerEvent event in velocityEventData) {
if (event is PointerDownEvent || event is PointerMoveEvent)
tracker.addPosition(event.timeStamp, event.position);
if (event is PointerUpEvent)
diff --git a/dev/benchmarks/microbenchmarks/lib/language/sync_star_bench.dart b/dev/benchmarks/microbenchmarks/lib/language/sync_star_bench.dart
index b757221..dba12ac 100644
--- a/dev/benchmarks/microbenchmarks/lib/language/sync_star_bench.dart
+++ b/dev/benchmarks/microbenchmarks/lib/language/sync_star_bench.dart
@@ -84,7 +84,7 @@
int sumIterable(Iterable<int> values) {
int result = 0;
- for (int value in values) {
+ for (final int value in values) {
result += value;
}
return result;
diff --git a/dev/benchmarks/microbenchmarks/lib/language/sync_star_semantics_bench.dart b/dev/benchmarks/microbenchmarks/lib/language/sync_star_semantics_bench.dart
index c5ffc2f..0672841 100644
--- a/dev/benchmarks/microbenchmarks/lib/language/sync_star_semantics_bench.dart
+++ b/dev/benchmarks/microbenchmarks/lib/language/sync_star_semantics_bench.dart
@@ -71,7 +71,7 @@
String consumeSpan(Iterable<InlineSpanSemanticsInformation> items) {
String result = '';
- for (InlineSpanSemanticsInformation span in items) {
+ for (final InlineSpanSemanticsInformation span in items) {
result += span.text;
}
return result;
@@ -81,7 +81,7 @@
Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoSyncStar(List<InlineSpanSemanticsInformation> inputs) sync* {
String workingText = '';
String workingLabel;
- for (InlineSpanSemanticsInformation info in inputs) {
+ for (final InlineSpanSemanticsInformation info in inputs) {
if (info.requiresOwnNode) {
if (workingText != null) {
yield InlineSpanSemanticsInformation(workingText, semanticsLabel: workingLabel ?? workingText);
@@ -110,7 +110,7 @@
String workingText = '';
String workingLabel;
final List<InlineSpanSemanticsInformation> result = <InlineSpanSemanticsInformation>[];
- for (InlineSpanSemanticsInformation info in inputs) {
+ for (final InlineSpanSemanticsInformation info in inputs) {
if (info.requiresOwnNode) {
if (workingText != null) {
result.add(InlineSpanSemanticsInformation(workingText, semanticsLabel: workingLabel ?? workingText));
diff --git a/dev/bots/analyze-sample-code.dart b/dev/bots/analyze-sample-code.dart
index f442234..2957f26 100644
--- a/dev/bots/analyze-sample-code.dart
+++ b/dev/bots/analyze-sample-code.dart
@@ -193,7 +193,7 @@
"import 'dart:typed_data';",
"import 'dart:ui' as ui;",
"import 'package:flutter_test/flutter_test.dart';",
- for (File file in _listDartFiles(Directory(_defaultFlutterPackage))) ...<String>[
+ for (final File file in _listDartFiles(Directory(_defaultFlutterPackage))) ...<String>[
'',
'// ${file.path}',
"import 'package:flutter/${path.basename(file.path)}';",
@@ -214,7 +214,7 @@
errors = _analyze(_tempDirectory, sections, snippets);
} finally {
if (errors.isNotEmpty) {
- for (String filePath in errors.keys) {
+ for (final String filePath in errors.keys) {
errors[filePath].forEach(stderr.writeln);
}
stderr.writeln('\nFound ${errors.length} sample code errors.');
@@ -310,7 +310,7 @@
final List<Section> sections = <Section>[];
final List<Snippet> snippets = <Snippet>[];
- for (File file in _listDartFiles(_flutterPackage, recursive: true)) {
+ for (final File file in _listDartFiles(_flutterPackage, recursive: true)) {
final String relativeFilePath = path.relative(file.path, from: _flutterPackage.path);
final List<String> sampleLines = file.readAsLinesSync();
final List<Section> preambleSections = <Section>[];
@@ -326,7 +326,7 @@
final List<String> block = <String>[];
List<String> snippetArgs = <String>[];
Line startLine;
- for (String line in sampleLines) {
+ for (final String line in sampleLines) {
lineNumber += 1;
final String trimmedLine = line.trim();
if (inSnippet) {
@@ -434,10 +434,10 @@
}
}
print('Found ${sections.length} sample code sections.');
- for (Section section in sections) {
+ for (final Section section in sections) {
sectionMap[_writeSection(section).path] = section;
}
- for (Snippet snippet in snippets) {
+ for (final Snippet snippet in snippets) {
final File snippetFile = _writeSnippet(snippet);
snippet.contents = snippetFile.readAsLinesSync();
snippetMap[snippetFile.absolute.path] = snippet;
@@ -576,7 +576,7 @@
);
bool unknownAnalyzerErrors = false;
final int headerLength = headers.length + 2;
- for (String error in errors) {
+ for (final String error in errors) {
final Match parts = errorPattern.matchAsPrefix(error);
if (parts != null) {
final String message = parts[2];
@@ -860,7 +860,7 @@
String toString() {
final StringBuffer buf = StringBuffer('snippet ${args.join(' ')}\n');
int count = start.line;
- for (String line in input) {
+ for (final String line in input) {
buf.writeln(' ${count.toString().padLeft(4, ' ')}: $line');
count++;
}
diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart
index 1da0458..f4a703c 100644
--- a/dev/bots/analyze.dart
+++ b/dev/bots/analyze.dart
@@ -147,11 +147,11 @@
Future<void> verifyDeprecations(String workingDirectory, { int minimumMatches = 2000 }) async {
final List<String> errors = <String>[];
- for (File file in _allFiles(workingDirectory, 'dart', minimumMatches: minimumMatches)) {
+ for (final File file in _allFiles(workingDirectory, 'dart', minimumMatches: minimumMatches)) {
int lineNumber = 0;
final List<String> lines = file.readAsLinesSync();
final List<int> linesWithDeprecations = <int>[];
- for (String line in lines) {
+ for (final String line in lines) {
if (line.contains(_findDeprecationPattern) &&
!line.endsWith(_ignoreDeprecation) &&
!line.contains(_grandfatheredDeprecation)) {
@@ -239,7 +239,7 @@
assert(!license.endsWith('\n'));
final String licensePattern = license + '\n' + (trailingBlank ? '\n' : '');
final List<String> errors = <String>[];
- for (File file in _allFiles(workingDirectory, extension, minimumMatches: minimumMatches)) {
+ for (final File file in _allFiles(workingDirectory, extension, minimumMatches: minimumMatches)) {
final String contents = file.readAsStringSync().replaceAll('\r\n', '\n');
if (contents.isEmpty)
continue; // let's not go down the /bin/true rabbit hole
@@ -270,8 +270,8 @@
final List<String> errors = <String>[];
assert("// foo\nimport 'binding_test.dart' as binding;\n'".contains(_testImportPattern));
final List<File> dartFiles = _allFiles(path.join(workingDirectory, 'packages'), 'dart', minimumMatches: 1500).toList();
- for (File file in dartFiles) {
- for (String line in file.readAsLinesSync()) {
+ for (final File file in dartFiles) {
+ for (final String line in file.readAsLinesSync()) {
final Match match = _testImportPattern.firstMatch(line);
if (match != null && !_exemptTestImports.contains(match.group(2)))
errors.add(file.path);
@@ -365,7 +365,7 @@
final Map<String, List<File>> packageToRegistrants = <String, List<File>>{};
- for (File file in flutterRootDir.listSync(recursive: true).whereType<File>().where(_isGeneratedPluginRegistrant)) {
+ for (final File file in flutterRootDir.listSync(recursive: true).whereType<File>().where(_isGeneratedPluginRegistrant)) {
final String package = _getPackageFor(file, flutterRootDir);
final List<File> registrants = packageToRegistrants.putIfAbsent(package, () => <File>[]);
registrants.add(file);
@@ -373,16 +373,16 @@
final Set<String> outOfDate = <String>{};
- for (String package in packageToRegistrants.keys) {
+ for (final String package in packageToRegistrants.keys) {
final Map<File, String> fileToContent = <File, String>{};
- for (File f in packageToRegistrants[package]) {
+ for (final File f in packageToRegistrants[package]) {
fileToContent[f] = f.readAsStringSync();
}
await runCommand(flutter, <String>['inject-plugins'],
workingDirectory: package,
outputMode: OutputMode.discard,
);
- for (File registrant in fileToContent.keys) {
+ for (final File registrant in fileToContent.keys) {
if (registrant.readAsStringSync() != fileToContent[registrant]) {
outOfDate.add(registrant.path);
}
@@ -422,20 +422,20 @@
}
// Verify that the imports are well-ordered.
final Map<String, Set<String>> dependencyMap = <String, Set<String>>{};
- for (String directory in directories) {
+ for (final String directory in directories) {
dependencyMap[directory] = _findFlutterDependencies(path.join(srcPath, directory), errors, checkForMeta: directory != 'foundation');
}
assert(dependencyMap['material'].contains('widgets') &&
dependencyMap['widgets'].contains('rendering') &&
dependencyMap['rendering'].contains('painting')); // to make sure we're convinced _findFlutterDependencies is finding some
- for (String package in dependencyMap.keys) {
+ for (final String package in dependencyMap.keys) {
if (dependencyMap[package].contains(package)) {
errors.add(
'One of the files in the $yellow$package$reset package imports that package recursively.'
);
}
}
- for (String package in dependencyMap.keys) {
+ for (final String package in dependencyMap.keys) {
final List<String> loop = _deepSearch<String>(dependencyMap, package);
if (loop != null) {
errors.add(
@@ -459,7 +459,7 @@
Future<void> verifyNoBadImportsInFlutterTools(String workingDirectory) async {
final List<String> errors = <String>[];
final List<File> files = _allFiles(path.join(workingDirectory, 'packages', 'flutter_tools', 'lib'), 'dart', minimumMatches: 200).toList();
- for (File file in files) {
+ for (final File file in files) {
if (file.readAsStringSync().contains('package:flutter_tools/')) {
errors.add('$yellow${file.path}$reset imports flutter_tools.');
}
@@ -535,7 +535,7 @@
.where((File file) => path.extension(file.path) != '.jar')
.toList();
final List<String> problems = <String>[];
- for (File file in files) {
+ for (final File file in files) {
final List<String> lines = file.readAsLinesSync();
for (int index = 0; index < lines.length; index += 1) {
if (lines[index].endsWith(' ')) {
@@ -1004,7 +1004,7 @@
.map<File>((String filename) => File(path.join(workingDirectory, filename)))
.toList();
final List<String> problems = <String>[];
- for (File file in files) {
+ for (final File file in files) {
final Uint8List bytes = file.readAsBytesSync();
try {
utf8.decode(bytes);
@@ -1156,7 +1156,7 @@
return _allFiles(srcPath, 'dart', minimumMatches: 1)
.map<Set<String>>((File file) {
final Set<String> result = <String>{};
- for (String line in file.readAsLinesSync()) {
+ for (final String line in file.readAsLinesSync()) {
Match match = _importPattern.firstMatch(line);
if (match != null)
result.add(match.group(2));
@@ -1180,7 +1180,7 @@
}
List<T> _deepSearch<T>(Map<T, Set<T>> map, T start, [ Set<T> seen ]) {
- for (T key in map[start]) {
+ for (final T key in map[start]) {
if (key == start)
continue; // we catch these separately
if (seen != null && seen.contains(key))
diff --git a/dev/bots/flutter_compact_formatter.dart b/dev/bots/flutter_compact_formatter.dart
index 5a4bbf6..0b5552c 100644
--- a/dev/bots/flutter_compact_formatter.dart
+++ b/dev/bots/flutter_compact_formatter.dart
@@ -160,7 +160,7 @@
void finish() {
final List<String> skipped = <String>[];
final List<String> failed = <String>[];
- for (TestResult result in _tests.values) {
+ for (final TestResult result in _tests.values) {
switch (result.status) {
case TestStatus.started:
failed.add('${_red}Unexpectedly failed to complete a test!');
diff --git a/dev/bots/prepare_package.dart b/dev/bots/prepare_package.dart
index ce9bad7..b45bb1d 100644
--- a/dev/bots/prepare_package.dart
+++ b/dev/bots/prepare_package.dart
@@ -354,7 +354,7 @@
// Create each of the templates, since they will call 'pub get' on
// themselves when created, and this will warm the cache with their
// dependencies too.
- for (String template in <String>['app', 'package', 'plugin']) {
+ for (final String template in <String>['app', 'package', 'plugin']) {
final String createName = path.join(tempDir.path, 'create_$template');
await _runFlutter(
<String>['create', '--template=$template', createName],
@@ -528,7 +528,7 @@
// Search for any entries with the same hash and channel and remove them.
final List<dynamic> releases = jsonData['releases'] as List<dynamic>;
jsonData['releases'] = <Map<String, dynamic>>[
- for (Map<String, dynamic> entry in releases.cast<Map<String, dynamic>>())
+ for (final Map<String, dynamic> entry in releases.cast<Map<String, dynamic>>())
if (entry['hash'] != newEntry['hash'] || entry['channel'] != newEntry['channel'])
entry,
newEntry,
diff --git a/dev/bots/run_command.dart b/dev/bots/run_command.dart
index 1407067..2577433 100644
--- a/dev/bots/run_command.dart
+++ b/dev/bots/run_command.dart
@@ -37,7 +37,7 @@
stderr.addStream(process.stderr);
final Stream<String> lines = process.stdout.transform(utf8.decoder).transform(const LineSplitter());
- await for (String line in lines)
+ await for (final String line in lines)
yield line;
final int exitCode = await process.exitCode;
diff --git a/dev/bots/test.dart b/dev/bots/test.dart
index 05fee88..92fd621 100644
--- a/dev/bots/test.dart
+++ b/dev/bots/test.dart
@@ -295,7 +295,7 @@
/// target app.
Future<void> _runBuildTests() async {
final Stream<FileSystemEntity> exampleDirectories = Directory(path.join(flutterRoot, 'examples')).list();
- await for (FileSystemEntity fileEntity in exampleDirectories) {
+ await for (final FileSystemEntity fileEntity in exampleDirectories) {
if (fileEntity is! Directory) {
continue;
}
@@ -817,7 +817,7 @@
last = '_last';
}
subshards['$subshard$last'] = () async {
- for (ShardRunner test in sublist)
+ for (final ShardRunner test in sublist)
await test();
};
}
@@ -1020,7 +1020,7 @@
item = parts[positionInTaskName];
}
if (item == null) {
- for (String currentItem in items.keys) {
+ for (final String currentItem in items.keys) {
print('$bold$key=$currentItem$reset');
await items[currentItem]();
print('');
diff --git a/dev/bots/test/fake_process_manager.dart b/dev/bots/test/fake_process_manager.dart
index 521e8c2..04d2317 100644
--- a/dev/bots/test/fake_process_manager.dart
+++ b/dev/bots/test/fake_process_manager.dart
@@ -34,7 +34,7 @@
Map<String, List<ProcessResult>> get fakeResults => _fakeResults;
set fakeResults(Map<String, List<ProcessResult>> value) {
_fakeResults = <String, List<ProcessResult>>{};
- for (String key in value.keys) {
+ for (final String key in value.keys) {
_fakeResults[key] = (value[key] ?? <ProcessResult>[ProcessResult(0, 0, '', '')]).toList();
}
}
@@ -46,7 +46,7 @@
/// parameters were in the same order.
void verifyCalls(List<String> calls) {
int index = 0;
- for (String call in calls) {
+ for (final String call in calls) {
expect(call.split(' '), orderedEquals(invocations[index].positionalArguments[0] as Iterable<dynamic>));
index++;
}
@@ -178,7 +178,7 @@
@override
Future<dynamic> close() async {
- for (Completer<dynamic> completer in completers) {
+ for (final Completer<dynamic> completer in completers) {
await completer.future;
}
completers.clear();
diff --git a/dev/bots/test/fake_process_manager_test.dart b/dev/bots/test/fake_process_manager_test.dart
index b74576c..6782c02 100644
--- a/dev/bots/test/fake_process_manager_test.dart
+++ b/dev/bots/test/fake_process_manager_test.dart
@@ -34,7 +34,7 @@
],
};
processManager.fakeResults = calls;
- for (String key in calls.keys) {
+ for (final String key in calls.keys) {
final Process process = await processManager.start(key.split(' '));
String output = '';
process.stdout.listen((List<int> item) {
@@ -56,7 +56,7 @@
],
};
processManager.fakeResults = calls;
- for (String key in calls.keys) {
+ for (final String key in calls.keys) {
final ProcessResult result = await processManager.run(key.split(' '));
expect(result.stdout, equals(calls[key][0].stdout));
}
@@ -73,7 +73,7 @@
],
};
processManager.fakeResults = calls;
- for (String key in calls.keys) {
+ for (final String key in calls.keys) {
final ProcessResult result = processManager.runSync(key.split(' '));
expect(result.stdout, equals(calls[key][0].stdout));
}
@@ -90,7 +90,7 @@
],
};
processManager.fakeResults = calls;
- for (String key in calls.keys) {
+ for (final String key in calls.keys) {
final Process process = await processManager.start(key.split(' '));
String output = '';
process.stdout.listen((List<int> item) {
diff --git a/dev/bots/test/prepare_package_test.dart b/dev/bots/test/prepare_package_test.dart
index b7054fe..9f4a122 100644
--- a/dev/bots/test/prepare_package_test.dart
+++ b/dev/bots/test/prepare_package_test.dart
@@ -35,7 +35,7 @@
);
}
});
- for (String platformName in <String>['macos', 'linux', 'windows']) {
+ for (final String platformName in <String>['macos', 'linux', 'windows']) {
final FakePlatform platform = FakePlatform(
operatingSystem: platformName,
environment: <String, String>{
diff --git a/dev/bots/test/test_test.dart b/dev/bots/test/test_test.dart
index ce2e3fb..debf9ca 100644
--- a/dev/bots/test/test_test.dart
+++ b/dev/bots/test/test_test.dart
@@ -27,7 +27,7 @@
'1.2.3+hotfix.1',
'1.2.3+hotfix.12-pre.12',
];
- for (String version in valid_versions) {
+ for (final String version in valid_versions) {
when(file.readAsString()).thenAnswer((Invocation invocation) => Future<String>.value(version));
expect(
await verifyVersion(file),
@@ -47,7 +47,7 @@
' 1.2.3',
'1.2.3-hotfix.1',
];
- for (String version in invalid_versions) {
+ for (final String version in invalid_versions) {
when(file.readAsString()).thenAnswer((Invocation invocation) => Future<String>.value(version));
expect(
await verifyVersion(file),
diff --git a/dev/bots/unpublish_package.dart b/dev/bots/unpublish_package.dart
index 3da5bf6..581cd8f 100644
--- a/dev/bots/unpublish_package.dart
+++ b/dev/bots/unpublish_package.dart
@@ -254,7 +254,7 @@
return bDate.compareTo(aDate);
});
jsonData['releases'] = releases;
- for (Channel channel in channels) {
+ for (final Channel channel in channels) {
if (!revisionsBeingRemoved.contains(jsonData['current_release'][getChannelName(channel)])) {
// Don't replace the current release if it's not one of the revisions we're removing.
continue;
@@ -276,7 +276,7 @@
Future<Map<Channel, Map<String, String>>> _getArchivePaths(List<Map<String, String>> releases) async {
final Set<String> hashes = <String>{};
final Map<Channel, Map<String, String>> paths = <Channel, Map<String, String>>{};
- for (Map<String, String> revision in releases) {
+ for (final Map<String, String> revision in releases) {
final String hash = revision['hash'];
final Channel channel = fromChannelName(revision['channel']);
hashes.add(hash);
@@ -350,9 +350,9 @@
Future<void> _cloudRemoveArchive(Map<Channel, Map<String, String>> paths) async {
final List<String> files = <String>[];
print('${confirmed ? 'Removing' : 'Would remove'} the following release archives:');
- for (Channel channel in paths.keys) {
+ for (final Channel channel in paths.keys) {
final Map<String, String> hashes = paths[channel];
- for (String hash in hashes.keys) {
+ for (final String hash in hashes.keys) {
final String file = '$gsReleaseFolder/${hashes[hash]}';
files.add(file);
print(' $file');
@@ -464,7 +464,7 @@
if (revisions.isEmpty) {
errorExit('Invalid argument: at least one --revision must be specified.');
}
- for (String revision in revisions) {
+ for (final String revision in revisions) {
if (revision.length != 40) {
errorExit('Invalid argument: --revision "$revision" must be the entire hash, not just a prefix.');
}
@@ -500,7 +500,7 @@
String message;
String stack;
try {
- for (PublishedPlatform platform in platforms) {
+ for (final PublishedPlatform platform in platforms) {
final ArchiveUnpublisher publisher = ArchiveUnpublisher(
tempDir,
revisions.toSet(),
diff --git a/dev/customer_testing/run_tests.dart b/dev/customer_testing/run_tests.dart
index 0087892..62133a4 100644
--- a/dev/customer_testing/run_tests.dart
+++ b/dev/customer_testing/run_tests.dart
@@ -102,7 +102,7 @@
print('');
}
- for (File file in files) {
+ for (final File file in files) {
if (verbose)
print('Processing ${file.path}...');
TestFile instructions;
@@ -127,7 +127,7 @@
try {
bool success;
bool showContacts = false;
- for (String fetchCommand in instructions.fetch) {
+ for (final String fetchCommand in instructions.fetch) {
success = await shell(fetchCommand, checkout, verbose: verbose, silentFailure: skipOnFetchFailure);
if (!success) {
if (skipOnFetchFailure) {
@@ -153,7 +153,7 @@
for (int iteration = 0; iteration < repeat; iteration += 1) {
if (verbose && repeat > 1)
print('Round ${iteration + 1} of $repeat.');
- for (String testCommand in instructions.tests) {
+ for (final String testCommand in instructions.tests) {
success = await shell(testCommand, tests, verbose: verbose);
if (!success) {
print('ERROR: One or more tests from ${path.basenameWithoutExtension(file.path)} failed.');
@@ -197,7 +197,7 @@
final List<String> fetch = <String>[];
final List<Directory> update = <Directory>[];
final List<String> test = <String>[];
- for (String line in file.readAsLinesSync().map((String line) => line.trim())) {
+ for (final String line in file.readAsLinesSync().map((String line) => line.trim())) {
if (line.isEmpty) {
// blank line
} else if (line.startsWith('#')) {
@@ -228,7 +228,7 @@
}
if (contacts.isEmpty)
throw FormatException('${errorPrefix}No contacts specified. At least one contact e-mail address must be specified.');
- for (String email in contacts) {
+ for (final String email in contacts) {
if (!email.contains(_email) || email.endsWith('@example.com'))
throw FormatException('${errorPrefix}The following e-mail address appears to be an invalid e-mail address: $email');
}
diff --git a/dev/devicelab/bin/run.dart b/dev/devicelab/bin/run.dart
index 9eaa691..cc2af62 100644
--- a/dev/devicelab/bin/run.dart
+++ b/dev/devicelab/bin/run.dart
@@ -59,7 +59,7 @@
final String localEngine = args['local-engine'] as String;
final String localEngineSrcPath = args['local-engine-src-path'] as String;
- for (String taskName in _taskNames) {
+ for (final String taskName in _taskNames) {
section('Running task "$taskName"');
final Map<String, dynamic> result = await runTask(
taskName,
@@ -95,7 +95,7 @@
}
// Only start skipping if user specified a task to continue from
final String stage = args['stage'] as String;
- for (ManifestTask task in tasks) {
+ for (final ManifestTask task in tasks) {
final bool isQualifyingStage = stage == null || task.stage == stage;
final bool isQualifyingHost = !(args['match-host-platform'] as bool) || task.isSupportedByHost();
if (isQualifyingHost && isQualifyingStage) {
@@ -116,7 +116,7 @@
'\n'
'This option may be repeated to specify multiple tasks.',
callback: (List<String> value) {
- for (String nameOrPath in value) {
+ for (final String nameOrPath in value) {
final List<String> fragments = path.split(nameOrPath);
final bool isDartFile = fragments.last.endsWith('.dart');
diff --git a/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart b/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart
index 99e6c0e..726ea17 100644
--- a/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart
+++ b/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart
@@ -114,7 +114,7 @@
section('Check profile, release builds has Dart AOT dylib');
- for (String mode in <String>['Profile', 'Release']) {
+ for (final String mode in <String>['Profile', 'Release']) {
final String appFrameworkPath = path.join(
outputPath,
mode,
@@ -159,7 +159,7 @@
section("Check all modes' engine dylib");
- for (String mode in <String>['Debug', 'Profile', 'Release']) {
+ for (final String mode in <String>['Debug', 'Profile', 'Release']) {
final String engineFrameworkPath = path.join(
outputPath,
mode,
@@ -194,7 +194,7 @@
section("Check all modes' engine header");
- for (String mode in <String>['Debug', 'Profile', 'Release']) {
+ for (final String mode in <String>['Debug', 'Profile', 'Release']) {
checkFileContains(
<String>['#include "FlutterEngine.h"'],
path.join(outputPath, mode, 'Flutter.framework', 'Headers', 'Flutter.h'),
@@ -203,7 +203,7 @@
section("Check all modes' have plugin dylib");
- for (String mode in <String>['Debug', 'Profile', 'Release']) {
+ for (final String mode in <String>['Debug', 'Profile', 'Release']) {
final String pluginFrameworkPath = path.join(
outputPath,
mode,
@@ -237,7 +237,7 @@
section("Check all modes' have generated plugin registrant");
- for (String mode in <String>['Debug', 'Profile', 'Release']) {
+ for (final String mode in <String>['Debug', 'Profile', 'Release']) {
final String registrantFrameworkPath = path.join(
outputPath,
mode,
diff --git a/dev/devicelab/bin/tasks/dartdocs.dart b/dev/devicelab/bin/tasks/dartdocs.dart
index 3bcaff6..4173a7b 100644
--- a/dev/devicelab/bin/tasks/dartdocs.dart
+++ b/dev/devicelab/bin/tasks/dartdocs.dart
@@ -40,7 +40,7 @@
print('^ not sure what to do with that line ^');
}
}
- await for (String entry in analysis.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
+ await for (final String entry in analysis.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
print('analyzer stderr: $entry');
if (entry.contains(' (ran in ') && !sawFinalLine) {
// ignore this line once
diff --git a/dev/devicelab/bin/tasks/flutter_gallery__transition_perf_with_semantics.dart b/dev/devicelab/bin/tasks/flutter_gallery__transition_perf_with_semantics.dart
index e201e52..8bf7c0a 100644
--- a/dev/devicelab/bin/tasks/flutter_gallery__transition_perf_with_semantics.dart
+++ b/dev/devicelab/bin/tasks/flutter_gallery__transition_perf_with_semantics.dart
@@ -16,7 +16,7 @@
final List<String> benchmarkScoreKeys = <String>[];
final Map<String, dynamic> data = <String, dynamic>{};
- for (String key in withSemantics.benchmarkScoreKeys) {
+ for (final String key in withSemantics.benchmarkScoreKeys) {
final String deltaKey = 'delta_$key';
data[deltaKey] = withSemantics.data[key] - withoutSemantics.data[key];
data['semantics_$key'] = withSemantics.data[key];
diff --git a/dev/devicelab/bin/tasks/flutter_test_performance.dart b/dev/devicelab/bin/tasks/flutter_test_performance.dart
index cba5b25..540fdb5 100644
--- a/dev/devicelab/bin/tasks/flutter_test_performance.dart
+++ b/dev/devicelab/bin/tasks/flutter_test_performance.dart
@@ -49,7 +49,7 @@
);
int badLines = 0;
TestStep step = TestStep.starting;
- await for (String entry in analysis.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
+ await for (final String entry in analysis.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
print('test stdout ($step): $entry');
if (step == TestStep.starting && entry == 'Building flutter tool...') {
// ignore this line
@@ -82,7 +82,7 @@
}
}
}
- await for (String entry in analysis.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
+ await for (final String entry in analysis.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter())) {
print('test stderr: $entry');
badLines += 1;
}
diff --git a/dev/devicelab/bin/tasks/gradle_non_android_plugin_test.dart b/dev/devicelab/bin/tasks/gradle_non_android_plugin_test.dart
index 594644f..56f9faa 100644
--- a/dev/devicelab/bin/tasks/gradle_non_android_plugin_test.dart
+++ b/dev/devicelab/bin/tasks/gradle_non_android_plugin_test.dart
@@ -50,7 +50,7 @@
final String pubspecString = pubspecFile.readAsStringSync();
final StringBuffer iosOnlyPubspec = StringBuffer();
- for (String line in pubspecString.split('\n')) {
+ for (final String line in pubspecString.split('\n')) {
if (line.startsWith(' androidPackage:')) {
continue;
}
diff --git a/dev/devicelab/bin/tasks/technical_debt__cost.dart b/dev/devicelab/bin/tasks/technical_debt__cost.dart
index c22f834..8f04c69 100644
--- a/dev/devicelab/bin/tasks/technical_debt__cost.dart
+++ b/dev/devicelab/bin/tasks/technical_debt__cost.dart
@@ -37,7 +37,7 @@
return 0.0;
final bool isTest = file.path.endsWith('_test.dart');
double total = 0.0;
- for (String line in await file.readAsLines()) {
+ for (final String line in await file.readAsLines()) {
if (line.contains(todoPattern))
total += todoCost;
if (line.contains(ignorePattern))
@@ -60,7 +60,7 @@
if (path.extension(file.path) != '.dart')
return 0;
int total = 0;
- for (String line in await file.readAsLines()) {
+ for (final String line in await file.readAsLines()) {
if (line.contains(globalsPattern))
total += 1;
}
@@ -74,7 +74,7 @@
workingDirectory: flutterDirectory.path,
);
double total = 0.0;
- await for (String entry in git.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()))
+ await for (final String entry in git.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()))
total += await findCostsForFile(File(path.join(flutterDirectory.path, entry)));
final int gitExitCode = await git.exitCode;
if (gitExitCode != 0)
@@ -89,7 +89,7 @@
workingDirectory: flutterDirectory.path,
);
int total = 0;
- await for (String entry in git.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()))
+ await for (final String entry in git.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()))
total += await findGlobalsForFile(File(path.join(flutterDirectory.path, entry)));
final int gitExitCode = await git.exitCode;
if (gitExitCode != 0)
diff --git a/dev/devicelab/bin/tasks/uncaught_image_error_linux.dart b/dev/devicelab/bin/tasks/uncaught_image_error_linux.dart
index 7c647ff..17f55c5 100644
--- a/dev/devicelab/bin/tasks/uncaught_image_error_linux.dart
+++ b/dev/devicelab/bin/tasks/uncaught_image_error_linux.dart
@@ -37,7 +37,7 @@
.transform(utf8.decoder)
.transform(const LineSplitter());
- await for (String line in lines) {
+ await for (final String line in lines) {
print(line);
if (line.contains('ERROR caught by framework')) {
passed = true;
diff --git a/dev/devicelab/lib/framework/adb.dart b/dev/devicelab/lib/framework/adb.dart
index fa07a86..ead9883 100644
--- a/dev/devicelab/lib/framework/adb.dart
+++ b/dev/devicelab/lib/framework/adb.dart
@@ -144,7 +144,7 @@
final List<String> output = (await eval(adbPath, <String>['devices', '-l'], canFail: false))
.trim().split('\n');
final List<String> results = <String>[];
- for (String line in output) {
+ for (final String line in output) {
// Skip lines like: * daemon started successfully *
if (line.startsWith('* daemon '))
continue;
@@ -172,7 +172,7 @@
@override
Future<Map<String, HealthCheckResult>> checkDevices() async {
final Map<String, HealthCheckResult> results = <String, HealthCheckResult>{};
- for (String deviceId in await discoverDevices()) {
+ for (final String deviceId in await discoverDevices()) {
try {
final AndroidDevice device = AndroidDevice(deviceId: deviceId);
// Just a smoke test that we can read wakefulness state
@@ -432,7 +432,7 @@
@override
Future<Map<String, HealthCheckResult>> checkDevices() async {
final Map<String, HealthCheckResult> results = <String, HealthCheckResult>{};
- for (String deviceId in await discoverDevices()) {
+ for (final String deviceId in await discoverDevices()) {
// TODO(ianh): do a more meaningful connectivity check than just recording the ID
results['ios-device-$deviceId'] = HealthCheckResult.success();
}
diff --git a/dev/devicelab/lib/framework/apk_utils.dart b/dev/devicelab/lib/framework/apk_utils.dart
index 2312672..ed83e83 100644
--- a/dev/devicelab/lib/framework/apk_utils.dart
+++ b/dev/devicelab/lib/framework/apk_utils.dart
@@ -191,7 +191,7 @@
/// Checks that the classes are contained in the APK, throws otherwise.
Future<void> checkApkContainsClasses(File apk, List<String> classes) async {
final ApkExtractor extractor = ApkExtractor(apk);
- for (String className in classes) {
+ for (final String className in classes) {
if (!(await extractor.containsClass(className))) {
throw Exception('APK doesn\'t contain class `$className`.');
}
diff --git a/dev/devicelab/lib/framework/framework.dart b/dev/devicelab/lib/framework/framework.dart
index e991c34..45381ff 100644
--- a/dev/devicelab/lib/framework/framework.dart
+++ b/dev/devicelab/lib/framework/framework.dart
@@ -179,7 +179,7 @@
message = 'success' {
const JsonEncoder prettyJson = JsonEncoder.withIndent(' ');
if (benchmarkScoreKeys != null) {
- for (String key in benchmarkScoreKeys) {
+ for (final String key in benchmarkScoreKeys) {
if (!data.containsKey(key)) {
throw 'Invalid Golem score key "$key". It does not exist in task '
'result data ${prettyJson.convert(data)}';
diff --git a/dev/devicelab/lib/framework/manifest.dart b/dev/devicelab/lib/framework/manifest.dart
index 6263a06..04b48b7 100644
--- a/dev/devicelab/lib/framework/manifest.dart
+++ b/dev/devicelab/lib/framework/manifest.dart
@@ -160,7 +160,7 @@
}
void _checkKeys(Map<dynamic, dynamic> map, String variableName, List<String> allowedKeys) {
- for (String key in map.keys.cast<String>()) {
+ for (final String key in map.keys.cast<String>()) {
if (!allowedKeys.contains(key)) {
throw ManifestError(
'Unrecognized property "$key" in $variableName. '
diff --git a/dev/devicelab/lib/framework/running_processes.dart b/dev/devicelab/lib/framework/running_processes.dart
index e438b18..cb09cf5 100644
--- a/dev/devicelab/lib/framework/running_processes.dart
+++ b/dev/devicelab/lib/framework/running_processes.dart
@@ -100,7 +100,7 @@
print(result.stdout);
return;
}
- for (RunningProcessInfo info in processPowershellOutput(result.stdout as String)) {
+ for (final RunningProcessInfo info in processPowershellOutput(result.stdout as String)) {
yield info;
}
}
@@ -122,7 +122,7 @@
int creationDateHeaderEnd;
int commandLineHeaderStart;
bool inTableBody = false;
- for (String line in output.split('\n')) {
+ for (final String line in output.split('\n')) {
if (line.startsWith('ProcessId')) {
commandLineHeaderStart = line.indexOf('CommandLine');
creationDateHeaderEnd = commandLineHeaderStart - 1;
@@ -191,7 +191,7 @@
print(result.stdout);
return;
}
- for (RunningProcessInfo info in processPsOutput(result.stdout as String, processName)) {
+ for (final RunningProcessInfo info in processPsOutput(result.stdout as String, processName)) {
yield info;
}
}
diff --git a/dev/devicelab/lib/framework/utils.dart b/dev/devicelab/lib/framework/utils.dart
index 9aa71be..2b54cc5 100644
--- a/dev/devicelab/lib/framework/utils.dart
+++ b/dev/devicelab/lib/framework/utils.dart
@@ -63,7 +63,7 @@
if (details != null && details.trim().isNotEmpty) {
buf.writeln();
// Indent details by 4 spaces
- for (String line in details.trim().split('\n')) {
+ for (final String line in details.trim().split('\n')) {
buf.writeln(' $line');
}
}
@@ -119,7 +119,7 @@
if (!target.existsSync())
target.createSync();
- for (FileSystemEntity entity in source.listSync(followLinks: false)) {
+ for (final FileSystemEntity entity in source.listSync(followLinks: false)) {
final String name = path.basename(entity.path);
if (entity is Directory && !entity.path.contains('.dart_tool'))
recursiveCopy(entity, Directory(path.join(target.path, name)));
@@ -286,7 +286,7 @@
await Future<void>.delayed(const Duration(seconds: 1));
// Whatever's left, kill it.
- for (ProcessInfo p in _runningProcesses) {
+ for (final ProcessInfo p in _runningProcesses) {
print('Force-quitting process:\n$p');
if (!p.process.kill()) {
print('Failed to force quit process');
@@ -636,7 +636,7 @@
/// Check that `collection` contains all entries in `values`.
void checkCollectionContains<T>(Iterable<T> values, Iterable<T> collection) {
- for (T value in values) {
+ for (final T value in values) {
if (!collection.contains(value)) {
throw TaskResult.failure('Expected to find `$value` in `${collection.toString()}`.');
}
@@ -645,7 +645,7 @@
/// Check that `collection` does not contain any entries in `values`
void checkCollectionDoesNotContain<T>(Iterable<T> values, Iterable<T> collection) {
- for (T value in values) {
+ for (final T value in values) {
if (collection.contains(value)) {
throw TaskResult.failure('Did not expect to find `$value` in `$collection`.');
}
@@ -656,7 +656,7 @@
/// [Pattern]s, otherwise throws a [TaskResult].
void checkFileContains(List<Pattern> patterns, String filePath) {
final String fileContent = File(filePath).readAsStringSync();
- for (Pattern pattern in patterns) {
+ for (final Pattern pattern in patterns) {
if (!fileContent.contains(pattern)) {
throw TaskResult.failure(
'Expected to find `$pattern` in `$filePath` '
diff --git a/dev/devicelab/lib/tasks/gallery.dart b/dev/devicelab/lib/tasks/gallery.dart
index e27b9bc..ae44b77 100644
--- a/dev/devicelab/lib/tasks/gallery.dart
+++ b/dev/devicelab/lib/tasks/gallery.dart
@@ -50,7 +50,7 @@
file('${galleryDirectory.path}/build/transition_durations.timeline.json').readAsStringSync(),
) as Map<String, dynamic>;
final Map<String, List<int>> transitions = <String, List<int>>{};
- for (String key in original.keys) {
+ for (final String key in original.keys) {
transitions[key.replaceAll('/', '')] = List<int>.from(original[key] as List<dynamic>);
}
diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart
index a1ad8fd..7ced54f 100644
--- a/dev/devicelab/lib/tasks/perf_tests.dart
+++ b/dev/devicelab/lib/tasks/perf_tests.dart
@@ -386,7 +386,7 @@
final RegExp metricExpression = RegExp(r'([a-zA-Z]+)\(CodeSize\)\: (\d+)');
final Map<String, dynamic> metrics = <String, dynamic>{};
- for (Match m in metricExpression.allMatches(compileLog)) {
+ for (final Match m in metricExpression.allMatches(compileLog)) {
metrics[_sdkNameToMetricName(m.group(1))] = int.parse(m.group(2));
}
if (metrics.length != _kSdkNameToMetricNameMapping.length) {
diff --git a/dev/devicelab/lib/tasks/plugin_tests.dart b/dev/devicelab/lib/tasks/plugin_tests.dart
index ab04539..cff0a7f 100644
--- a/dev/devicelab/lib/tasks/plugin_tests.dart
+++ b/dev/devicelab/lib/tasks/plugin_tests.dart
@@ -12,7 +12,7 @@
/// Combines several TaskFunctions with trivial success value into one.
TaskFunction combine(List<TaskFunction> tasks) {
return () async {
- for (TaskFunction task in tasks) {
+ for (final TaskFunction task in tasks) {
final TaskResult result = await task();
if (result.failed) {
return result;
diff --git a/dev/devicelab/lib/tasks/save_catalog_screenshots.dart b/dev/devicelab/lib/tasks/save_catalog_screenshots.dart
index 062c0b4..214e240 100644
--- a/dev/devicelab/lib/tasks/save_catalog_screenshots.dart
+++ b/dev/devicelab/lib/tasks/save_catalog_screenshots.dart
@@ -120,14 +120,14 @@
String prefix, // Prefix for all file names.
}) async {
final List<String> screenshots = <String>[
- for (FileSystemEntity entity in directory.listSync())
+ for (final FileSystemEntity entity in directory.listSync())
if (entity is File && entity.path.endsWith('.png'))
entity.path,
];
final List<String> largeNames = <String>[]; // Cloud storage names for the full res screenshots.
final List<String> smallNames = <String>[]; // Likewise for the scaled down screenshots.
- for (String path in screenshots) {
+ for (final String path in screenshots) {
final String name = screenshotName(path);
largeNames.add('$commit/$prefix$name.png');
smallNames.add('$commit/$prefix${name}_small.png');
diff --git a/dev/devicelab/test/manifest_test.dart b/dev/devicelab/test/manifest_test.dart
index 4a642fe..8282a9f 100644
--- a/dev/devicelab/test/manifest_test.dart
+++ b/dev/devicelab/test/manifest_test.dart
@@ -19,7 +19,7 @@
expect(task.stage, 'devicelab');
expect(task.requiredAgentCapabilities, <String>['linux/android']);
- for (ManifestTask task in manifest.tasks) {
+ for (final ManifestTask task in manifest.tasks) {
final File taskFile = File('bin/tasks/${task.name}.dart');
expect(taskFile.existsSync(), true,
reason: 'File ${taskFile.path} corresponding to manifest task "${task.name}" not found');
diff --git a/dev/devicelab/test/run_test.dart b/dev/devicelab/test/run_test.dart
index 90f43f3..8090590 100644
--- a/dev/devicelab/test/run_test.dart
+++ b/dev/devicelab/test/run_test.dart
@@ -19,7 +19,7 @@
final ProcessResult scriptProcess = processManager.runSync(<String>[
dart,
'bin/run.dart',
- for (String testName in testNames) ...<String>['-t', testName],
+ for (final String testName in testNames) ...<String>['-t', testName],
]);
return scriptProcess;
}
diff --git a/dev/integration_tests/android_semantics_testing/lib/src/common.dart b/dev/integration_tests/android_semantics_testing/lib/src/common.dart
index 06fa05f..79cf2f4 100644
--- a/dev/integration_tests/android_semantics_testing/lib/src/common.dart
+++ b/dev/integration_tests/android_semantics_testing/lib/src/common.dart
@@ -149,7 +149,7 @@
/// Gets a list of [AndroidSemanticsActions] which are defined for the node.
List<AndroidSemanticsAction> getActions() => <AndroidSemanticsAction>[
- for (int id in (_values['actions'] as List<dynamic>).cast<int>()) AndroidSemanticsAction.deserialize(id),
+ for (final int id in (_values['actions'] as List<dynamic>).cast<int>()) AndroidSemanticsAction.deserialize(id),
];
@override
diff --git a/dev/integration_tests/android_semantics_testing/test_driver/main_test.dart b/dev/integration_tests/android_semantics_testing/test_driver/main_test.dart
index fe759fe..ef76002 100644
--- a/dev/integration_tests/android_semantics_testing/test_driver/main_test.dart
+++ b/dev/integration_tests/android_semantics_testing/test_driver/main_test.dart
@@ -399,7 +399,7 @@
// catch up.
await Future<void>.delayed(const Duration(milliseconds: 1500));
- for (String item in popupItems) {
+ for (final String item in popupItems) {
expect(
await getSemantics(find.byValueKey('$popupKeyValue.$item')),
hasAndroidSemantics(
@@ -423,7 +423,7 @@
await driver.tap(find.byValueKey(popupButtonKeyValue));
await Future<void>.delayed(const Duration(milliseconds: 1500));
- for (String item in popupItems) {
+ for (final String item in popupItems) {
expect(
await getSemantics(find.byValueKey('$popupKeyValue.$item')),
hasAndroidSemantics(
@@ -467,7 +467,7 @@
try {
await Future<void>.delayed(const Duration(milliseconds: 1500));
- for (String item in popupItems) {
+ for (final String item in popupItems) {
// There are two copies of each item, so we want to find the version
// that is in the overlay, not the one in the dropdown.
expect(
@@ -503,7 +503,7 @@
await driver.tap(find.byValueKey(dropdownButtonKeyValue));
await Future<void>.delayed(const Duration(milliseconds: 1500));
- for (String item in popupItems) {
+ for (final String item in popupItems) {
// There are two copies of each item, so we want to find the version
// that is in the overlay, not the one in the dropdown.
expect(
@@ -572,7 +572,7 @@
),
reason: "Alert OK button doesn't have the right semantics");
- for (String item in <String>['Title', 'Body1', 'Body2']) {
+ for (final String item in <String>['Title', 'Body1', 'Body2']) {
expect(
await getSemantics(find.byValueKey('$alertKeyValue.$item')),
hasAndroidSemantics(
@@ -611,7 +611,7 @@
),
reason: "Alert OK button doesn't have the right semantics");
- for (String item in <String>['Title', 'Body1', 'Body2']) {
+ for (final String item in <String>['Title', 'Body1', 'Body2']) {
expect(
await getSemantics(find.byValueKey('$alertKeyValue.$item')),
hasAndroidSemantics(
diff --git a/dev/integration_tests/android_views/lib/motion_event_diff.dart b/dev/integration_tests/android_views/lib/motion_event_diff.dart
index f5f073f..b42d9e8 100644
--- a/dev/integration_tests/android_views/lib/motion_event_diff.dart
+++ b/dev/integration_tests/android_views/lib/motion_event_diff.dart
@@ -122,7 +122,7 @@
'${messagePrefix}keys (expected: ${expected.keys} actual: ${actual.keys} ');
return;
}
- for (String key in expected.keys) {
+ for (final String key in expected.keys) {
if (excludeKeys.contains(key))
continue;
if (doublesApproximatelyMatch(expected[key], actual[key]))
diff --git a/dev/integration_tests/android_views/lib/motion_events_page.dart b/dev/integration_tests/android_views/lib/motion_events_page.dart
index 48be7de..a4b508b 100644
--- a/dev/integration_tests/android_views/lib/motion_events_page.dart
+++ b/dev/integration_tests/android_views/lib/motion_events_page.dart
@@ -123,7 +123,7 @@
await channel.invokeMethod<void>('pipeFlutterViewEvents');
await viewChannel.invokeMethod<void>('pipeTouchEvents');
print('replaying ${recordedEvents.length} motion events');
- for (Map<String, dynamic> event in recordedEvents.reversed) {
+ for (final Map<String, dynamic> event in recordedEvents.reversed) {
await channel.invokeMethod<void>('synthesizeEvent', event);
}
diff --git a/dev/integration_tests/channels/lib/src/test_step.dart b/dev/integration_tests/channels/lib/src/test_step.dart
index 4662d03..2a26467 100644
--- a/dev/integration_tests/channels/lib/src/test_step.dart
+++ b/dev/integration_tests/channels/lib/src/test_step.dart
@@ -174,7 +174,7 @@
bool _deepEqualsMap(Map<dynamic, dynamic> a, Map<dynamic, dynamic> b) {
if (a.length != b.length)
return false;
- for (dynamic key in a.keys) {
+ for (final dynamic key in a.keys) {
if (!b.containsKey(key) || !_deepEquals(a[key], b[key]))
return false;
}
diff --git a/dev/manual_tests/lib/actions.dart b/dev/manual_tests/lib/actions.dart
index 16acf1e..2663b54 100644
--- a/dev/manual_tests/lib/actions.dart
+++ b/dev/manual_tests/lib/actions.dart
@@ -77,7 +77,7 @@
/// May only be called by subclasses.
@protected
void notifyListeners() {
- for (VoidCallback callback in _listeners) {
+ for (final VoidCallback callback in _listeners) {
callback();
}
}
diff --git a/dev/manual_tests/lib/overlay_geometry.dart b/dev/manual_tests/lib/overlay_geometry.dart
index 54f68c7..a223fa4 100644
--- a/dev/manual_tests/lib/overlay_geometry.dart
+++ b/dev/manual_tests/lib/overlay_geometry.dart
@@ -159,7 +159,7 @@
setState(() {
final double dy = markersScrollOffset - notification.metrics.extentBefore;
markersScrollOffset = notification.metrics.extentBefore;
- for (MarkerType type in markers.keys) {
+ for (final MarkerType type in markers.keys) {
final Offset oldPosition = markers[type];
markers[type] = oldPosition.translate(0.0, dy);
}
@@ -199,7 +199,7 @@
),
),
),
- for (MarkerType type in markers.keys)
+ for (final MarkerType type in markers.keys)
Marker(type: type, position: markers[type]),
],
);
diff --git a/dev/manual_tests/lib/raw_keyboard.dart b/dev/manual_tests/lib/raw_keyboard.dart
index fabcb62..5f78ca3 100644
--- a/dev/manual_tests/lib/raw_keyboard.dart
+++ b/dev/manual_tests/lib/raw_keyboard.dart
@@ -127,8 +127,8 @@
if (_event.character != null) {
dataText.add(Text('character: ${_event.character}'));
}
- for (ModifierKey modifier in data.modifiersPressed.keys) {
- for (KeyboardSide side in KeyboardSide.values) {
+ for (final ModifierKey modifier in data.modifiersPressed.keys) {
+ for (final KeyboardSide side in KeyboardSide.values) {
if (data.isModifierPressed(modifier, side: side)) {
dataText.add(
Text('${_getEnumName(side)} ${_getEnumName(modifier).replaceAll('Modifier', '')} pressed'),
diff --git a/dev/manual_tests/lib/text.dart b/dev/manual_tests/lib/text.dart
index 37b421c..3ca82ac 100644
--- a/dev/manual_tests/lib/text.dart
+++ b/dev/manual_tests/lib/text.dart
@@ -343,7 +343,7 @@
if (node.children == null || node.children.isEmpty)
return 0;
int result = 0;
- for (TextSpan child in node.children.cast<TextSpan>())
+ for (final TextSpan child in node.children.cast<TextSpan>())
result = math.max(result, depthOf(child));
return result;
}
@@ -582,7 +582,7 @@
child: ListBody(
children: <Widget>[
_wrap(null),
- for (TextDecorationStyle style in TextDecorationStyle.values) _wrap(style),
+ for (final TextDecorationStyle style in TextDecorationStyle.values) _wrap(style),
],
),
),
@@ -675,7 +675,7 @@
child: IntrinsicWidth(
child: ListBody(
children: <Widget>[
- for (String font in androidFonts)
+ for (final String font in androidFonts)
Text(
multiScript,
style: style.copyWith(
diff --git a/dev/snippets/lib/snippets.dart b/dev/snippets/lib/snippets.dart
index 3e955b0..b21c795 100644
--- a/dev/snippets/lib/snippets.dart
+++ b/dev/snippets/lib/snippets.dart
@@ -104,7 +104,7 @@
final List<String> result = <String>[];
const HtmlEscape htmlEscape = HtmlEscape();
String language;
- for (_ComponentTuple injection in injections) {
+ for (final _ComponentTuple injection in injections) {
if (!injection.name.startsWith('code')) {
continue;
}
@@ -152,7 +152,7 @@
final List<_ComponentTuple> components = <_ComponentTuple>[];
String language;
final RegExp codeStartEnd = RegExp(r'^\s*```([-\w]+|[-\w]+ ([-\w]+))?\s*$');
- for (String line in input.split('\n')) {
+ for (final String line in input.split('\n')) {
final Match match = codeStartEnd.firstMatch(line);
if (match != null) { // If we saw the start or end of a code block
inCodeBlock = !inCodeBlock;
@@ -188,7 +188,7 @@
String _addLineNumbers(String app) {
final StringBuffer buffer = StringBuffer();
int count = 0;
- for (String line in app.split('\n')) {
+ for (final String line in app.split('\n')) {
count++;
buffer.writeln('${count.toString().padLeft(5, ' ')}: $line');
}
diff --git a/dev/tools/dartdoc.dart b/dev/tools/dartdoc.dart
index 103697e..7c3a436 100644
--- a/dev/tools/dartdoc.dart
+++ b/dev/tools/dartdoc.dart
@@ -57,7 +57,7 @@
// https://github.com/dart-lang/dartdoc/issues/1982
buf.writeln('version: 0.0.0');
buf.writeln('dependencies:');
- for (String package in findPackageNames()) {
+ for (final String package in findPackageNames()) {
buf.writeln(' $package:');
buf.writeln(' sdk: flutter');
}
@@ -72,7 +72,7 @@
libDir.createSync();
final StringBuffer contents = StringBuffer('library temp_doc;\n\n');
- for (String libraryRef in libraryRefs()) {
+ for (final String libraryRef in libraryRefs()) {
contents.writeln('import \'package:$libraryRef\';');
}
File('$kDocsRoot/lib/temp_doc.dart').writeAsStringSync(contents.toString());
@@ -313,7 +313,7 @@
if (!destDir.existsSync())
destDir.createSync(recursive: true);
- for (FileSystemEntity entity in srcDir.listSync()) {
+ for (final FileSystemEntity entity in srcDir.listSync()) {
final String newPath = path.join(destDir.path, path.basename(entity.path));
if (entity is File) {
final File newFile = File(newPath);
@@ -361,7 +361,7 @@
'$kPublishRoot/api/material/Tooltip-class.html',
'$kPublishRoot/api/widgets/Widget-class.html',
];
- for (String canary in canaries) {
+ for (final String canary in canaries) {
if (!File(canary).existsSync())
throw Exception('Missing "$canary", which probably means the documentation failed to build correctly.');
}
@@ -470,9 +470,9 @@
/// Returns import or on-disk paths for all libraries in the Flutter SDK.
Iterable<String> libraryRefs() sync* {
- for (Directory dir in findPackages()) {
+ for (final Directory dir in findPackages()) {
final String dirName = path.basename(dir.path);
- for (FileSystemEntity file in Directory('${dir.path}/lib').listSync()) {
+ for (final FileSystemEntity file in Directory('${dir.path}/lib').listSync()) {
if (file is File && file.path.endsWith('.dart')) {
yield '$dirName/${path.basename(file.path)}';
}
diff --git a/dev/tools/gen_keycodes/lib/code_gen.dart b/dev/tools/gen_keycodes/lib/code_gen.dart
index 8d7d2d2..c7f006a 100644
--- a/dev/tools/gen_keycodes/lib/code_gen.dart
+++ b/dev/tools/gen_keycodes/lib/code_gen.dart
@@ -20,7 +20,7 @@
final StringBuffer result = StringBuffer();
final List<String> words = input.split(RegExp(r'\s+'));
String currentLine = words.removeAt(0);
- for (String word in words) {
+ for (final String word in words) {
if ((currentLine.length + word.length) < wrapWidth) {
currentLine += ' $word';
} else {
@@ -37,7 +37,7 @@
/// Gets the generated definitions of PhysicalKeyboardKeys.
String get physicalDefinitions {
final StringBuffer definitions = StringBuffer();
- for (Key entry in keyData.data) {
+ for (final Key entry in keyData.data) {
final String firstComment = wrapString('Represents the location of the '
'"${entry.commentName}" key on a generalized keyboard.');
final String otherComments = wrapString('See the function '
@@ -73,7 +73,7 @@
}
}
- for (Key entry in keyData.data) {
+ for (final Key entry in keyData.data) {
printKey(
entry.flutterId,
entry.keyLabel,
@@ -81,7 +81,7 @@
entry.commentName,
);
}
- for (String name in Key.synonyms.keys) {
+ for (final String name in Key.synonyms.keys) {
// Use the first item in the synonyms as a template for the ID to use.
// It won't end up being the same value because it'll be in the pseudo-key
// plane.
@@ -99,8 +99,8 @@
String get logicalSynonyms {
final StringBuffer synonyms = StringBuffer();
- for (String name in Key.synonyms.keys) {
- for (String synonym in Key.synonyms[name].cast<String>()) {
+ for (final String name in Key.synonyms.keys) {
+ for (final String synonym in Key.synonyms[name].cast<String>()) {
final String keyName = upperCamelToLowerCamel(synonym);
synonyms.writeln(' $keyName: $name,');
}
@@ -124,7 +124,7 @@
/// This generates the map of USB HID codes to physical keys.
String get predefinedHidCodeMap {
final StringBuffer scanCodeMap = StringBuffer();
- for (Key entry in keyData.data) {
+ for (final Key entry in keyData.data) {
scanCodeMap.writeln(' ${toHex(entry.usbHidCode)}: ${entry.constantName},');
}
return scanCodeMap.toString().trimRight();
@@ -133,10 +133,10 @@
/// THis generates the map of Flutter key codes to logical keys.
String get predefinedKeyCodeMap {
final StringBuffer keyCodeMap = StringBuffer();
- for (Key entry in keyData.data) {
+ for (final Key entry in keyData.data) {
keyCodeMap.writeln(' ${toHex(entry.flutterId, digits: 10)}: ${entry.constantName},');
}
- for (String entry in Key.synonyms.keys) {
+ for (final String entry in Key.synonyms.keys) {
// Use the first item in the synonyms as a template for the ID to use.
// It won't end up being the same value because it'll be in the pseudo-key
// plane.
@@ -152,9 +152,9 @@
/// This generates the map of GLFW number pad key codes to logical keys.
String get glfwNumpadMap {
final StringBuffer glfwNumpadMap = StringBuffer();
- for (Key entry in numpadKeyData) {
+ for (final Key entry in numpadKeyData) {
if (entry.glfwKeyCodes != null) {
- for (int code in entry.glfwKeyCodes.cast<int>()) {
+ for (final int code in entry.glfwKeyCodes.cast<int>()) {
glfwNumpadMap.writeln(' $code: LogicalKeyboardKey.${entry.constantName},');
}
}
@@ -165,9 +165,9 @@
/// This generates the map of GLFW key codes to logical keys.
String get glfwKeyCodeMap {
final StringBuffer glfwKeyCodeMap = StringBuffer();
- for (Key entry in keyData.data) {
+ for (final Key entry in keyData.data) {
if (entry.glfwKeyCodes != null) {
- for (int code in entry.glfwKeyCodes.cast<int>()) {
+ for (final int code in entry.glfwKeyCodes.cast<int>()) {
glfwKeyCodeMap.writeln(' $code: LogicalKeyboardKey.${entry.constantName},');
}
}
@@ -178,7 +178,7 @@
/// This generates the map of XKB USB HID codes to physical keys.
String get xkbScanCodeMap {
final StringBuffer xkbScanCodeMap = StringBuffer();
- for (Key entry in keyData.data) {
+ for (final Key entry in keyData.data) {
if (entry.xKbScanCode != null) {
xkbScanCodeMap.writeln(' ${toHex(entry.xKbScanCode)}: PhysicalKeyboardKey.${entry.constantName},');
}
@@ -189,9 +189,9 @@
/// This generates the map of Android key codes to logical keys.
String get androidKeyCodeMap {
final StringBuffer androidKeyCodeMap = StringBuffer();
- for (Key entry in keyData.data) {
+ for (final Key entry in keyData.data) {
if (entry.androidKeyCodes != null) {
- for (int code in entry.androidKeyCodes.cast<int>()) {
+ for (final int code in entry.androidKeyCodes.cast<int>()) {
androidKeyCodeMap.writeln(' $code: LogicalKeyboardKey.${entry.constantName},');
}
}
@@ -202,9 +202,9 @@
/// This generates the map of Android number pad key codes to logical keys.
String get androidNumpadMap {
final StringBuffer androidKeyCodeMap = StringBuffer();
- for (Key entry in numpadKeyData) {
+ for (final Key entry in numpadKeyData) {
if (entry.androidKeyCodes != null) {
- for (int code in entry.androidKeyCodes.cast<int>()) {
+ for (final int code in entry.androidKeyCodes.cast<int>()) {
androidKeyCodeMap.writeln(' $code: LogicalKeyboardKey.${entry.constantName},');
}
}
@@ -215,9 +215,9 @@
/// This generates the map of Android scan codes to physical keys.
String get androidScanCodeMap {
final StringBuffer androidScanCodeMap = StringBuffer();
- for (Key entry in keyData.data) {
+ for (final Key entry in keyData.data) {
if (entry.androidScanCodes != null) {
- for (int code in entry.androidScanCodes.cast<int>()) {
+ for (final int code in entry.androidScanCodes.cast<int>()) {
androidScanCodeMap.writeln(' $code: PhysicalKeyboardKey.${entry.constantName},');
}
}
@@ -228,7 +228,7 @@
/// This generates the map of macOS key codes to physical keys.
String get macOsScanCodeMap {
final StringBuffer macOsScanCodeMap = StringBuffer();
- for (Key entry in keyData.data) {
+ for (final Key entry in keyData.data) {
if (entry.macOsScanCode != null) {
macOsScanCodeMap.writeln(' ${toHex(entry.macOsScanCode)}: PhysicalKeyboardKey.${entry.constantName},');
}
@@ -239,7 +239,7 @@
/// This generates the map of macOS number pad key codes to logical keys.
String get macOsNumpadMap {
final StringBuffer macOsNumPadMap = StringBuffer();
- for (Key entry in numpadKeyData) {
+ for (final Key entry in numpadKeyData) {
if (entry.macOsScanCode != null) {
macOsNumPadMap.writeln(' ${toHex(entry.macOsScanCode)}: LogicalKeyboardKey.${entry.constantName},');
}
@@ -249,7 +249,7 @@
String get macOsFunctionKeyMap {
final StringBuffer macOsFunctionKeyMap = StringBuffer();
- for (Key entry in functionKeyData) {
+ for (final Key entry in functionKeyData) {
if (entry.macOsScanCode != null) {
macOsFunctionKeyMap.writeln(' ${toHex(entry.macOsScanCode)}: LogicalKeyboardKey.${entry.constantName},');
}
@@ -260,7 +260,7 @@
/// This generates the map of Fuchsia key codes to logical keys.
String get fuchsiaKeyCodeMap {
final StringBuffer fuchsiaKeyCodeMap = StringBuffer();
- for (Key entry in keyData.data) {
+ for (final Key entry in keyData.data) {
if (entry.usbHidCode != null) {
fuchsiaKeyCodeMap.writeln(' ${toHex(entry.flutterId)}: LogicalKeyboardKey.${entry.constantName},');
}
@@ -271,7 +271,7 @@
/// This generates the map of Fuchsia USB HID codes to physical keys.
String get fuchsiaHidCodeMap {
final StringBuffer fuchsiaScanCodeMap = StringBuffer();
- for (Key entry in keyData.data) {
+ for (final Key entry in keyData.data) {
if (entry.usbHidCode != null) {
fuchsiaScanCodeMap.writeln(' ${toHex(entry.usbHidCode)}: PhysicalKeyboardKey.${entry.constantName},');
}
@@ -282,7 +282,7 @@
/// This generates the map of Web KeyboardEvent codes to logical keys.
String get webLogicalKeyMap {
final StringBuffer result = StringBuffer();
- for (Key entry in keyData.data) {
+ for (final Key entry in keyData.data) {
if (entry.name != null) {
result.writeln(" '${entry.name}': LogicalKeyboardKey.${entry.constantName},");
}
@@ -293,7 +293,7 @@
/// This generates the map of Web KeyboardEvent codes to physical keys.
String get webPhysicalKeyMap {
final StringBuffer result = StringBuffer();
- for (Key entry in keyData.data) {
+ for (final Key entry in keyData.data) {
if (entry.name != null) {
result.writeln(" '${entry.name}': PhysicalKeyboardKey.${entry.constantName},");
}
@@ -304,7 +304,7 @@
/// This generates the map of Web number pad codes to logical keys.
String get webNumpadMap {
final StringBuffer result = StringBuffer();
- for (Key entry in numpadKeyData) {
+ for (final Key entry in numpadKeyData) {
if (entry.name != null) {
result.writeln(" '${entry.name}': LogicalKeyboardKey.${entry.constantName},");
}
@@ -359,7 +359,7 @@
static String _injectDictionary(String template, Map<String, String> dictionary) {
String result = template;
- for (String key in dictionary.keys) {
+ for (final String key in dictionary.keys) {
result = result.replaceAll('@@@$key@@@', dictionary[key]);
}
return result;
diff --git a/dev/tools/gen_keycodes/lib/key_data.dart b/dev/tools/gen_keycodes/lib/key_data.dart
index 9c755a0..8853f73 100644
--- a/dev/tools/gen_keycodes/lib/key_data.dart
+++ b/dev/tools/gen_keycodes/lib/key_data.dart
@@ -53,18 +53,18 @@
/// Parses the given JSON data and populates the data structure from it.
KeyData.fromJson(Map<String, dynamic> contentMap) {
data = <Key>[
- for (String key in contentMap.keys) Key.fromJsonMapEntry(key, contentMap[key] as Map<String, List<dynamic>>),
+ for (final String key in contentMap.keys) Key.fromJsonMapEntry(key, contentMap[key] as Map<String, List<dynamic>>),
];
}
/// Converts the data structure into a JSON structure that can be parsed by
/// [KeyData.fromJson].
Map<String, dynamic> toJson() {
- for (Key entry in data) {
+ for (final Key entry in data) {
// Android Key names
entry.androidKeyNames = _nameToAndroidName[entry.constantName]?.cast<String>();
if (entry.androidKeyNames != null && entry.androidKeyNames.isNotEmpty) {
- for (String androidKeyName in entry.androidKeyNames) {
+ for (final String androidKeyName in entry.androidKeyNames) {
if (_nameToAndroidKeyCode[androidKeyName] != null) {
entry.androidKeyCodes ??= <int>[];
entry.androidKeyCodes.add(_nameToAndroidKeyCode[androidKeyName]);
@@ -79,7 +79,7 @@
// GLFW key names
entry.glfwKeyNames = _nameToGlfwName[entry.constantName]?.cast<String>();
if (entry.glfwKeyNames != null && entry.glfwKeyNames.isNotEmpty) {
- for (String glfwKeyName in entry.glfwKeyNames) {
+ for (final String glfwKeyName in entry.glfwKeyNames) {
if (_nameToGlfwKeyCode[glfwKeyName] != null) {
entry.glfwKeyCodes ??= <int>[];
entry.glfwKeyCodes.add(_nameToGlfwKeyCode[glfwKeyName]);
@@ -89,7 +89,7 @@
}
final Map<String, dynamic> outputMap = <String, dynamic>{};
- for (Key entry in data) {
+ for (final Key entry in data) {
outputMap[entry.constantName] = entry.toJson();
}
return outputMap;
@@ -178,7 +178,7 @@
headerFile = headerFile.replaceAllMapped(enumBlock, (Match match) => match.group(1));
final RegExp enumEntry = RegExp(r'''AKEYCODE_([A-Z0-9_]+)\s*=\s*([0-9]+),?''');
final Map<String, int> result = <String, int>{};
- for (Match match in enumEntry.allMatches(headerFile)) {
+ for (final Match match in enumEntry.allMatches(headerFile)) {
result[match.group(1)] = int.parse(match.group(2));
}
return result;
@@ -193,7 +193,7 @@
// Only get the KEY definitions, ignore the rest (mouse, joystick, etc).
final RegExp enumEntry = RegExp(r'''define GLFW_KEY_([A-Z0-9_]+)\s*([A-Z0-9_]+),?''');
final Map<String, dynamic> replaced = <String, dynamic>{};
- for (Match match in enumEntry.allMatches(headerFile)) {
+ for (final Match match in enumEntry.allMatches(headerFile)) {
replaced[match.group(1)] = int.tryParse(match.group(2)) ?? match.group(2).replaceAll('GLFW_KEY_', '');
}
final Map<String, int> result = <String, int>{};
diff --git a/dev/tools/java_and_objc_doc.dart b/dev/tools/java_and_objc_doc.dart
index 7f41dff..2a0f836 100644
--- a/dev/tools/java_and_objc_doc.dart
+++ b/dev/tools/java_and_objc_doc.dart
@@ -56,7 +56,7 @@
print('Extracting $docName to ${output.path}');
output.createSync(recursive: true);
- for (ArchiveFile af in archive) {
+ for (final ArchiveFile af in archive) {
if (!af.name.endsWith('/')) {
final File file = File('${output.path}/${af.name}');
file.createSync(recursive: true);
diff --git a/dev/tools/localization/bin/encode_kn_arb_files.dart b/dev/tools/localization/bin/encode_kn_arb_files.dart
index 805b9b3..6477a5d 100644
--- a/dev/tools/localization/bin/encode_kn_arb_files.dart
+++ b/dev/tools/localization/bin/encode_kn_arb_files.dart
@@ -36,7 +36,7 @@
}
void encodeBundleTranslations(Map<String, dynamic> bundle) {
- for (String key in bundle.keys) {
+ for (final String key in bundle.keys) {
// The ARB file resource "attributes" for foo are called @foo. Don't need
// to encode them.
if (key.startsWith('@'))
@@ -54,7 +54,7 @@
void checkEncodedTranslations(Map<String, dynamic> encodedBundle, Map<String, dynamic> bundle) {
bool errorFound = false;
const JsonDecoder decoder = JsonDecoder();
- for (String key in bundle.keys) {
+ for (final String key in bundle.keys) {
if (decoder.convert('"${encodedBundle[key]}"') != bundle[key]) {
stderr.writeln(' encodedTranslation for $key does not match original value "${bundle[key]}"');
errorFound = true;
@@ -67,7 +67,7 @@
void rewriteBundle(File file, Map<String, dynamic> bundle) {
final StringBuffer contents = StringBuffer();
contents.writeln('{');
- for (String key in bundle.keys) {
+ for (final String key in bundle.keys) {
contents.writeln(' "$key": "${bundle[key]}"${key == bundle.keys.last ? '' : ','}');
}
contents.writeln('}');
diff --git a/dev/tools/localization/bin/gen_date_localizations.dart b/dev/tools/localization/bin/gen_date_localizations.dart
index b9c5f72..5c80509 100644
--- a/dev/tools/localization/bin/gen_date_localizations.dart
+++ b/dev/tools/localization/bin/gen_date_localizations.dart
@@ -167,7 +167,7 @@
final Set<String> supportedLocales = <String>{};
final RegExp filenameRE = RegExp(r'(?:material|cupertino)_(\w+)\.arb$');
final Directory supportedLocalesDirectory = Directory(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n'));
- for (FileSystemEntity entity in supportedLocalesDirectory.listSync()) {
+ for (final FileSystemEntity entity in supportedLocalesDirectory.listSync()) {
final String filePath = entity.path;
if (FileSystemEntity.isFileSync(filePath) && filenameRE.hasMatch(filePath))
supportedLocales.add(filenameRE.firstMatch(filePath)[1]);
@@ -181,7 +181,7 @@
.listSync()
.whereType<File>()
.where((File file) => file.path.endsWith('.json'));
- for (File file in files) {
+ for (final File file in files) {
final String locale = path.basenameWithoutExtension(file.path);
localeFiles[locale] = file;
}
diff --git a/dev/tools/localization/bin/gen_localizations.dart b/dev/tools/localization/bin/gen_localizations.dart
index 5b84a4a..70f343c 100644
--- a/dev/tools/localization/bin/gen_localizations.dart
+++ b/dev/tools/localization/bin/gen_localizations.dart
@@ -87,7 +87,7 @@
// Used to calculate if there are any corresponding countries for a given language and script.
final Map<LocaleInfo, Set<String>> languageAndScriptToCountryCodes = <LocaleInfo, Set<String>>{};
final Set<String> allResourceIdentifiers = <String>{};
- for (LocaleInfo locale in localeToResources.keys.toList()..sort()) {
+ for (final LocaleInfo locale in localeToResources.keys.toList()..sort()) {
if (locale.scriptCode != null) {
languageToScriptCodes[locale.languageCode] ??= <String>{};
languageToScriptCodes[locale.languageCode].add(locale.scriptCode);
@@ -129,13 +129,13 @@
final List<String> allKeys = allResourceIdentifiers.toList()..sort();
final List<String> languageCodes = languageToLocales.keys.toList()..sort();
final LocaleInfo canonicalLocale = LocaleInfo.fromString('en');
- for (String languageName in languageCodes) {
+ for (final String languageName in languageCodes) {
final LocaleInfo languageLocale = LocaleInfo.fromString(languageName);
output.writeln(generateClassDeclaration(languageLocale, generatedClassPrefix, baseClass));
output.writeln(generateConstructor(languageLocale));
final Map<String, String> languageResources = localeToResources[languageLocale];
- for (String key in allKeys) {
+ for (final String key in allKeys) {
final Map<String, dynamic> attributes = localeToResourceAttributes[canonicalLocale][key] as Map<String, dynamic>;
output.writeln(generateGetter(key, languageResources[key], attributes, languageLocale));
}
@@ -146,7 +146,7 @@
scriptCodeCount = languageToScriptCodes[languageName].length;
// Language has scriptCodes, so we need to properly fallback countries to corresponding
// script default values before language default values.
- for (String scriptCode in languageToScriptCodes[languageName]) {
+ for (final String scriptCode in languageToScriptCodes[languageName]) {
final LocaleInfo scriptBaseLocale = LocaleInfo.fromString(languageName + '_' + scriptCode);
output.writeln(generateClassDeclaration(
scriptBaseLocale,
@@ -155,7 +155,7 @@
));
output.writeln(generateConstructor(scriptBaseLocale));
final Map<String, String> scriptResources = localeToResources[scriptBaseLocale];
- for (String key in scriptResources.keys.toList()..sort()) {
+ for (final String key in scriptResources.keys.toList()..sort()) {
if (languageResources[key] == scriptResources[key])
continue;
final Map<String, dynamic> attributes = localeToResourceAttributes[canonicalLocale][key] as Map<String, dynamic>;
@@ -164,7 +164,7 @@
output.writeln('}');
final List<LocaleInfo> localeCodes = languageToLocales[languageName]..sort();
- for (LocaleInfo locale in localeCodes) {
+ for (final LocaleInfo locale in localeCodes) {
if (locale.originalString == languageName)
continue;
if (locale.originalString == languageName + '_' + scriptCode)
@@ -179,7 +179,7 @@
));
output.writeln(generateConstructor(locale));
final Map<String, String> localeResources = localeToResources[locale];
- for (String key in localeResources.keys) {
+ for (final String key in localeResources.keys) {
// When script fallback contains the key, we compare to it instead of language fallback.
if (scriptResources.containsKey(key) ? scriptResources[key] == localeResources[key] : languageResources[key] == localeResources[key])
continue;
@@ -193,7 +193,7 @@
// No scriptCode. Here, we do not compare against script default (because it
// doesn't exist).
final List<LocaleInfo> localeCodes = languageToLocales[languageName]..sort();
- for (LocaleInfo locale in localeCodes) {
+ for (final LocaleInfo locale in localeCodes) {
if (locale.originalString == languageName)
continue;
countryCodeCount += 1;
@@ -204,7 +204,7 @@
'$generatedClassPrefix${camelCase(languageLocale)}',
));
output.writeln(generateConstructor(locale));
- for (String key in localeResources.keys) {
+ for (final String key in localeResources.keys) {
if (languageResources[key] == localeResources[key])
continue;
final Map<String, dynamic> attributes = localeToResourceAttributes[canonicalLocale][key] as Map<String, dynamic>;
@@ -262,7 +262,7 @@
/// [$baseClass.delegate].
$factoryDeclaration
switch (locale.languageCode) {''');
- for (String language in languageToLocales.keys) {
+ for (final String language in languageToLocales.keys) {
// Only one instance of the language.
if (languageToLocales[language].length == 1) {
output.writeln('''
@@ -272,7 +272,7 @@
output.writeln('''
case '$language': {
switch (locale.countryCode) {''');
- for (LocaleInfo locale in languageToLocales[language]) {
+ for (final LocaleInfo locale in languageToLocales[language]) {
if (locale.originalString == language)
continue;
assert(locale.length > 1);
@@ -290,14 +290,14 @@
output.writeln('''
case '$language': {
switch (locale.scriptCode) {''');
- for (String scriptCode in languageToScriptCodes[language]) {
+ for (final String scriptCode in languageToScriptCodes[language]) {
final LocaleInfo scriptLocale = LocaleInfo.fromString(language + '_' + scriptCode);
output.writeln('''
case '$scriptCode': {''');
if (languageAndScriptToCountryCodes.containsKey(scriptLocale)) {
output.writeln('''
switch (locale.countryCode) {''');
- for (LocaleInfo locale in languageToLocales[language]) {
+ for (final LocaleInfo locale in languageToLocales[language]) {
if (locale.countryCode == null)
continue;
else
@@ -326,7 +326,7 @@
} else {
// Not Explicitly defined, fallback to first locale with the same language and
// script:
- for (LocaleInfo locale in languageToLocales[language]) {
+ for (final LocaleInfo locale in languageToLocales[language]) {
if (locale.scriptCode != scriptCode)
continue;
if (languageAndScriptToCountryCodes.containsKey(scriptLocale)) {
@@ -345,7 +345,7 @@
if (hasCountryCode) {
output.writeln('''
switch (locale.countryCode) {''');
- for (LocaleInfo locale in languageToLocales[language]) {
+ for (final LocaleInfo locale in languageToLocales[language]) {
if (locale.originalString == language)
continue;
assert(locale.length > 1);
diff --git a/dev/tools/localization/gen_l10n.dart b/dev/tools/localization/gen_l10n.dart
index 5281c44..c3dad4e 100644
--- a/dev/tools/localization/gen_l10n.dart
+++ b/dev/tools/localization/gen_l10n.dart
@@ -270,7 +270,7 @@
final Map<String, dynamic> attributesMap = bundle['@$key'] as Map<String, dynamic>;
if (attributesMap != null && attributesMap.containsKey('placeholders')) {
final Map<String, dynamic> placeholders = attributesMap['placeholders'] as Map<String, dynamic>;
- for (String placeholder in placeholders.keys) {
+ for (final String placeholder in placeholders.keys) {
final dynamic value = placeholders[placeholder];
if (
value is Map<String, dynamic> &&
@@ -302,7 +302,7 @@
final Map<String, dynamic> placeholders = attributesMap['placeholders'] as Map<String, dynamic>;
if (placeholders.isNotEmpty) {
final List<String> argumentList = <String>[];
- for (String placeholder in placeholders.keys) {
+ for (final String placeholder in placeholders.keys) {
final dynamic value = placeholders[placeholder];
if (
value is Map<String, dynamic> &&
@@ -328,7 +328,7 @@
String message = bundle[key] as String;
final Map<String, dynamic> attributesMap = bundle['@$key'] as Map<String, dynamic>;
final Map<String, dynamic> placeholders = attributesMap['placeholders'] as Map<String, dynamic>;
- for (String placeholder in placeholders.keys) {
+ for (final String placeholder in placeholders.keys) {
final dynamic value = placeholders[placeholder];
if (value is Map<String, dynamic> && _isDateParameter(value)) {
message = message.replaceAll('{$placeholder}', '\$${placeholder}String');
@@ -388,7 +388,7 @@
// To make it easier to parse the plurals message, temporarily replace each
// "{placeholder}" parameter with "#placeholder#".
String message = arbBundle[resourceId] as String;
- for (String placeholder in placeholders)
+ for (final String placeholder in placeholders)
message = message.replaceAll('{$placeholder}', '#$placeholder#');
final Map<String, String> pluralIds = <String, String>{
@@ -406,12 +406,12 @@
...genIntlMethodArgs(arbBundle, resourceId),
];
- for (String pluralKey in pluralIds.keys) {
+ for (final String pluralKey in pluralIds.keys) {
final RegExp expRE = RegExp('($pluralKey){([^}]+)}');
final RegExpMatch match = expRE.firstMatch(message);
if (match != null && match.groupCount == 2) {
String argValue = match.group(2);
- for (String placeholder in placeholders) {
+ for (final String placeholder in placeholders) {
final dynamic value = placeholdersMap[placeholder];
if (value is Map<String, dynamic> && _isDateParameter(value)) {
argValue = argValue.replaceAll('#$placeholder#', '\$${placeholder}String');
@@ -435,7 +435,7 @@
const String suffix = '),\n ];';
String resultingProperty = prefix;
- for (LocaleInfo locale in supportedLocales) {
+ for (final LocaleInfo locale in supportedLocales) {
final String languageCode = locale.languageCode;
final String countryCode = locale.countryCode;
@@ -668,7 +668,7 @@
.toList();
final List<LocaleInfo> localeInfoList = <LocaleInfo>[];
- for (File file in fileSystemEntityList) {
+ for (final File file in fileSystemEntityList) {
final String filePath = file.path;
if (arbFilenameRE.hasMatch(filePath)) {
final Map<String, dynamic> arbContents = json.decode(file.readAsStringSync()) as Map<String, dynamic>;
@@ -705,7 +705,7 @@
}));
if (preferredSupportedLocales != null) {
- for (LocaleInfo preferredLocale in preferredSupportedLocales) {
+ for (final LocaleInfo preferredLocale in preferredSupportedLocales) {
if (!localeInfoList.contains(preferredLocale)) {
throw L10nException(
'The preferred supported locale, \'$preferredLocale\', cannot be '
@@ -750,7 +750,7 @@
}
final List<String> sortedArbKeys = bundle.keys.toList()..sort();
- for (String key in sortedArbKeys) {
+ for (final String key in sortedArbKeys) {
if (key.startsWith('@'))
continue;
if (!_isValidGetterAndMethodName(key))
diff --git a/dev/tools/localization/localizations_utils.dart b/dev/tools/localization/localizations_utils.dart
index 61d830d..9813d433 100644
--- a/dev/tools/localization/localizations_utils.dart
+++ b/dev/tools/localization/localizations_utils.dart
@@ -155,7 +155,7 @@
/// overwrite the existing assumed data.
final Set<LocaleInfo> assumedLocales = <LocaleInfo>{};
- for (FileSystemEntity entity in directory.listSync().toList()..sort(sortFilesByPath)) {
+ for (final FileSystemEntity entity in directory.listSync().toList()..sort(sortFilesByPath)) {
final String entityPath = entity.path;
if (FileSystemEntity.isFileSync(entityPath) && filenamePattern.hasMatch(entityPath)) {
final String localeString = filenamePattern.firstMatch(entityPath)[1];
@@ -166,7 +166,7 @@
final Map<String, String> resources = localeToResources[locale];
final Map<String, dynamic> attributes = localeToResourceAttributes[locale];
final Map<String, dynamic> bundle = json.decode(file.readAsStringSync()) as Map<String, dynamic>;
- for (String key in bundle.keys) {
+ for (final String key in bundle.keys) {
// The ARB file resource "attributes" for foo are called @foo.
if (key.startsWith('@'))
attributes[key.substring(1)] = bundle[key];
@@ -270,7 +270,7 @@
Map<String, List<String>> _parseSection(String section) {
final Map<String, List<String>> result = <String, List<String>>{};
List<String> lastHeading;
- for (String line in section.split('\n')) {
+ for (final String line in section.split('\n')) {
if (line == '')
continue;
if (line.startsWith(' ')) {
@@ -304,7 +304,7 @@
final String body = (await response.cast<List<int>>().transform<String>(utf8.decoder).toList()).join('');
client.close(force: true);
final List<Map<String, List<String>>> sections = body.split('%%').skip(1).map<Map<String, List<String>>>(_parseSection).toList();
- for (Map<String, List<String>> section in sections) {
+ for (final Map<String, List<String>> section in sections) {
assert(section.containsKey('Type'), section.toString());
final String type = section['Type'].single;
if (type == 'language' || type == 'region' || type == 'script') {
diff --git a/dev/tools/localization/localizations_validator.dart b/dev/tools/localization/localizations_validator.dart
index 17cd9c8..e6f4560 100644
--- a/dev/tools/localization/localizations_validator.dart
+++ b/dev/tools/localization/localizations_validator.dart
@@ -38,7 +38,7 @@
final Map<String, dynamic> bundle = json.decode(file.readAsStringSync()) as Map<String, dynamic>;
- for (String resourceId in bundle.keys) {
+ for (final String resourceId in bundle.keys) {
if (resourceId.startsWith('@'))
continue;
@@ -55,7 +55,7 @@
errorMessages.writeln('A value was not specified for @$resourceId');
}
- for (String atResourceId in bundle.keys) {
+ for (final String atResourceId in bundle.keys) {
if (!atResourceId.startsWith('@'))
continue;
diff --git a/dev/tools/mega_gallery.dart b/dev/tools/mega_gallery.dart
index 7dcaa66..c7cd9e7 100644
--- a/dev/tools/mega_gallery.dart
+++ b/dev/tools/mega_gallery.dart
@@ -134,7 +134,7 @@
if (!target.existsSync())
target.createSync(recursive: true);
- for (FileSystemEntity entity in source.listSync(followLinks: false)) {
+ for (final FileSystemEntity entity in source.listSync(followLinks: false)) {
final String name = path.basename(entity.path);
if (entity is Directory) {
@@ -165,7 +165,7 @@
SourceStats getStatsFor(Directory dir, [SourceStats stats]) {
stats ??= SourceStats();
- for (FileSystemEntity entity in dir.listSync(recursive: false, followLinks: false)) {
+ for (final FileSystemEntity entity in dir.listSync(recursive: false, followLinks: false)) {
final String name = path.basename(entity.path);
if (entity is File && name.endsWith('.dart')) {
stats.files += 1;
diff --git a/dev/tools/update_icons.dart b/dev/tools/update_icons.dart
index d5b07b0..7b0128a 100644
--- a/dev/tools/update_icons.dart
+++ b/dev/tools/update_icons.dart
@@ -182,7 +182,7 @@
String regenerateIconsFile(String iconData, String codepointData) {
final StringBuffer buf = StringBuffer();
bool generating = false;
- for (String line in LineSplitter.split(iconData)) {
+ for (final String line in LineSplitter.split(iconData)) {
if (!generating)
buf.writeln(line);
if (line.contains(kBeginGeneratedMark)) {
diff --git a/dev/tools/vitool/bin/main.dart b/dev/tools/vitool/bin/main.dart
index 29d24d2..9bab9d3 100644
--- a/dev/tools/vitool/bin/main.dart
+++ b/dev/tools/vitool/bin/main.dart
@@ -65,7 +65,7 @@
}
final List<FrameData> frames = <FrameData>[
- for (String filePath in argResults.rest) interpretSvg(filePath),
+ for (final String filePath in argResults.rest) interpretSvg(filePath),
];
final StringBuffer generatedSb = StringBuffer();
diff --git a/dev/tools/vitool/lib/vitool.dart b/dev/tools/vitool/lib/vitool.dart
index 52e07e5..df713c2 100644
--- a/dev/tools/vitool/lib/vitool.dart
+++ b/dev/tools/vitool/lib/vitool.dart
@@ -59,7 +59,7 @@
sb.write('const $className $varName = const $className(\n');
sb.write('${kIndent}const Size(${size.x}, ${size.y}),\n');
sb.write('${kIndent}const <_PathFrames>[\n');
- for (PathAnimation path in paths)
+ for (final PathAnimation path in paths)
sb.write(path.toDart());
sb.write('$kIndent],\n');
sb.write(');');
@@ -117,11 +117,11 @@
final StringBuffer sb = StringBuffer();
sb.write('${kIndent * 2}const _PathFrames(\n');
sb.write('${kIndent * 3}opacities: const <double>[\n');
- for (double opacity in opacities)
+ for (final double opacity in opacities)
sb.write('${kIndent * 4}$opacity,\n');
sb.write('${kIndent * 3}],\n');
sb.write('${kIndent * 3}commands: const <_PathCommand>[\n');
- for (PathCommandAnimation command in commands)
+ for (final PathCommandAnimation command in commands)
sb.write(command.toDart());
sb.write('${kIndent * 3}],\n');
sb.write('${kIndent * 2}),\n');
@@ -166,9 +166,9 @@
}
final StringBuffer sb = StringBuffer();
sb.write('${kIndent * 4}const $dartCommandClass(\n');
- for (List<Point<double>> pointFrames in points) {
+ for (final List<Point<double>> pointFrames in points) {
sb.write('${kIndent * 5}const <Offset>[\n');
- for (Point<double> point in pointFrames)
+ for (final Point<double> point in pointFrames)
sb.write('${kIndent * 6}const Offset(${point.x}, ${point.y}),\n');
sb.write('${kIndent * 5}],\n');
}
@@ -201,7 +201,7 @@
List<SvgPath> _interpretSvgGroup(List<XmlNode> children, _Transform transform) {
final List<SvgPath> paths = <SvgPath>[];
- for (XmlNode node in children) {
+ for (final XmlNode node in children) {
if (node.nodeType != XmlNodeType.ELEMENT)
continue;
final XmlElement element = node as XmlElement;
@@ -304,7 +304,7 @@
final SvgPathCommandBuilder commandsBuilder = SvgPathCommandBuilder();
if (!_pathCommandValidator.hasMatch(dAttr))
throw Exception('illegal or unsupported path d expression: $dAttr');
- for (Match match in _pathCommandMatcher.allMatches(dAttr)) {
+ for (final Match match in _pathCommandMatcher.allMatches(dAttr)) {
final String commandType = match.group(1);
final String pointStr = match.group(2);
commands.add(commandsBuilder.build(commandType, parsePoints(pointStr)));
@@ -469,7 +469,7 @@
throw Exception('illegal or unsupported transform: $transform');
final Iterable<Match> matches =_transformCommand.allMatches(transform).toList().reversed;
Matrix3 result = Matrix3.identity();
- for (Match m in matches) {
+ for (final Match m in matches) {
final String command = m.group(1);
final String params = m.group(2);
if (command == 'translate') {