Uncontroversial and backwards compatible 2.0 SDK fixes (#13723)

Small code changes as part of moving the framework SDK forward to a 2.0 dev version.
This commit is contained in:
Leaf Petersen
2017-12-21 13:39:03 -08:00
committed by GitHub
parent ecb708ee3a
commit b3cfa785c4
13 changed files with 38 additions and 39 deletions

View File

@@ -50,11 +50,11 @@ class BenchmarkResultPrinter {
}
String _printJson() {
return JSON.encode(new Map<String, double>.fromIterable(
_results,
key: (_BenchmarkResult result) => result.name,
value: (_BenchmarkResult result) => result.value,
));
final Map<String, double> results = <String, double>{};
for (_BenchmarkResult result in _results) {
results[result.name] = result.value;
}
return JSON.encode(results);
}
String _printPlainText() {

View File

@@ -373,11 +373,10 @@ Future<Null> _verifyNoBadImports(String workingDirectory) async {
);
}
// Verify that the imports are well-ordered.
final Map<String, Set<String>> dependencyMap = new Map<String, Set<String>>.fromIterable(
directories,
key: (String directory) => directory,
value: (String directory) => _findDependencies(path.join(srcPath, directory), errors, checkForMeta: directory != 'foundation'),
);
final Map<String, Set<String>> dependencyMap = <String, Set<String>>{};
for (String directory in directories) {
dependencyMap[directory] = _findDependencies(path.join(srcPath, directory), errors, checkForMeta: directory != 'foundation');
}
for (String package in dependencyMap.keys) {
if (dependencyMap[package].contains(package)) {
errors.add(

View File

@@ -53,10 +53,10 @@ class GalleryTransitionTest {
final Map<String, List<int>> original = JSON.decode(file(
'${galleryDirectory.path}/build/transition_durations.timeline.json')
.readAsStringSync());
final Map<String, List<int>> transitions = new Map<String, List<int>>.fromIterable(
original.keys,
key: (String key) => key.replaceAll('/', ''),
value: (String key) => original[key]);
final Map<String, List<int>> transitions = <String, List<int>>{};
for (String key in original.keys) {
transitions[key.replaceAll('/', '')] = original[key];
}
final Map<String, dynamic> summary = JSON.decode(file('${galleryDirectory.path}/build/transitions.timeline_summary.json').readAsStringSync());

View File

@@ -240,11 +240,10 @@ class CompileTest {
watch.stop();
final RegExp metricExpression = new RegExp(r'([a-zA-Z]+)\(CodeSize\)\: (\d+)');
final Map<String, dynamic> metrics = new Map<String, dynamic>.fromIterable(
metricExpression.allMatches(compileLog),
key: (Match m) => _sdkNameToMetricName(m.group(1)),
value: (Match m) => int.parse(m.group(2)),
);
final Map<String, dynamic> metrics = <String, dynamic>{};
for (Match m in metricExpression.allMatches(compileLog)) {
metrics[_sdkNameToMetricName(m.group(1))] = int.parse(m.group(2));
}
metrics['aot_snapshot_compile_millis'] = watch.elapsedMilliseconds;
return metrics;

View File

@@ -18,7 +18,7 @@ class _FlavorState extends State<Flavor> {
@override
void initState() {
super.initState();
const MethodChannel('flavor').invokeMethod('getFlavor').then((String flavor) {
const MethodChannel('flavor').invokeMethod('getFlavor').then((Object flavor) {
setState(() {
_flavor = flavor;
});

View File

@@ -125,7 +125,7 @@ String _jsonToMap(dynamic json) {
if (json is Iterable)
return 'const <dynamic>[${json.map(_jsonToMap).join(',')}]';
if (json is Map) {
if (json is Map<String, dynamic>) {
final StringBuffer buffer = new StringBuffer('const <String, dynamic>{');
json.forEach((String key, dynamic value) {
buffer.writeln(_jsonToMapEntry(key, value));