Unverified Commit b3cfa785 authored by Leaf Petersen's avatar Leaf Petersen Committed by GitHub

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.
parent ecb708ee
......@@ -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() {
......
......@@ -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(
......
......@@ -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());
......
......@@ -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;
......
......@@ -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;
});
......
......@@ -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));
......
......@@ -149,17 +149,15 @@ class GalleryAppState extends State<GalleryApp> {
);
}
final Map<String, WidgetBuilder> _kRoutes =
new Map<String, WidgetBuilder>.fromIterable(
final Map<String, WidgetBuilder> _kRoutes = <String, WidgetBuilder>{};
for (GalleryItem item in kAllGalleryItems) {
// For a different example of how to set up an application routing table
// using named routes, consider the example in the Navigator class documentation:
// https://docs.flutter.io/flutter/widgets/Navigator-class.html
kAllGalleryItems,
key: (GalleryItem item) => item.routeName,
value: (GalleryItem item) {
return (BuildContext context) => _applyScaleFactor(item.buildRoute(context));
},
);
_kRoutes[item.routeName] = (BuildContext context) {
return _applyScaleFactor(item.buildRoute(context));
};
}
return new MaterialApp(
title: 'Flutter Gallery',
......
......@@ -40,7 +40,7 @@ class _PlatformChannelState extends State<PlatformChannel> {
eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError);
}
void _onEvent(String event) {
void _onEvent(Object event) {
setState(() {
_chargingStatus =
"Battery status: ${event == 'charging' ? '' : 'dis'}charging.";
......
......@@ -40,7 +40,7 @@ class _PlatformChannelState extends State<PlatformChannel> {
eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError);
}
void _onEvent(String event) {
void _onEvent(Object event) {
setState(() {
_chargingStatus =
"Battery status: ${event == 'charging' ? '' : 'dis'}charging.";
......
......@@ -19,7 +19,7 @@ class StockStrings {
static Future<StockStrings> load(Locale locale) {
return initializeMessages(locale.toString())
.then((Null _) {
.then((Object _) {
return new StockStrings(locale);
});
}
......
......@@ -459,7 +459,8 @@ abstract class WidgetsBinding extends BindingBase with SchedulerBinding, Gesture
observer.didHaveMemoryPressure();
}
Future<dynamic> _handleSystemMessage(Map<String, dynamic> message) async {
Future<Null> _handleSystemMessage(Object systemMessage) async {
final Map<String, dynamic> message = systemMessage;
final String type = message['type'];
switch (type) {
case 'memoryPressure':
......
......@@ -300,11 +300,12 @@ class _TableElement extends RenderObjectElement {
void update(Table newWidget) {
assert(!_debugWillReattachChildren);
assert(() { _debugWillReattachChildren = true; return true; }());
final Map<LocalKey, List<Element>> oldKeyedRows = new Map<LocalKey, List<Element>>.fromIterable(
_children.where((_TableElementRow row) => row.key != null),
key: (_TableElementRow row) => row.key,
value: (_TableElementRow row) => row.children
);
final Map<LocalKey, List<Element>> oldKeyedRows = <LocalKey, List<Element>>{};
for (_TableElementRow row in _children) {
if (row.key != null) {
oldKeyedRows[row.key] = row.children;
}
}
final Iterator<_TableElementRow> oldUnkeyedRows = _children.where((_TableElementRow row) => row.key == null).iterator;
final List<_TableElementRow> newChildren = <_TableElementRow>[];
final Set<List<Element>> taken = new Set<List<Element>>();
......
......@@ -12,7 +12,8 @@ void main() {
test('Semantic announcement', () async {
final List<Map<String, dynamic>> log = <Map<String, dynamic>>[];
SystemChannels.accessibility.setMockMessageHandler((Map<String, dynamic> message) async {
SystemChannels.accessibility.setMockMessageHandler((Object mockMessage) async {
final Map<String, dynamic> message = mockMessage;
log.add(message);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment