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 { ...@@ -50,11 +50,11 @@ class BenchmarkResultPrinter {
} }
String _printJson() { String _printJson() {
return JSON.encode(new Map<String, double>.fromIterable( final Map<String, double> results = <String, double>{};
_results, for (_BenchmarkResult result in _results) {
key: (_BenchmarkResult result) => result.name, results[result.name] = result.value;
value: (_BenchmarkResult result) => result.value, }
)); return JSON.encode(results);
} }
String _printPlainText() { String _printPlainText() {
......
...@@ -373,11 +373,10 @@ Future<Null> _verifyNoBadImports(String workingDirectory) async { ...@@ -373,11 +373,10 @@ Future<Null> _verifyNoBadImports(String workingDirectory) async {
); );
} }
// Verify that the imports are well-ordered. // Verify that the imports are well-ordered.
final Map<String, Set<String>> dependencyMap = new Map<String, Set<String>>.fromIterable( final Map<String, Set<String>> dependencyMap = <String, Set<String>>{};
directories, for (String directory in directories) {
key: (String directory) => directory, dependencyMap[directory] = _findDependencies(path.join(srcPath, directory), errors, checkForMeta: directory != 'foundation');
value: (String directory) => _findDependencies(path.join(srcPath, directory), errors, checkForMeta: directory != 'foundation'), }
);
for (String package in dependencyMap.keys) { for (String package in dependencyMap.keys) {
if (dependencyMap[package].contains(package)) { if (dependencyMap[package].contains(package)) {
errors.add( errors.add(
......
...@@ -53,10 +53,10 @@ class GalleryTransitionTest { ...@@ -53,10 +53,10 @@ class GalleryTransitionTest {
final Map<String, List<int>> original = JSON.decode(file( final Map<String, List<int>> original = JSON.decode(file(
'${galleryDirectory.path}/build/transition_durations.timeline.json') '${galleryDirectory.path}/build/transition_durations.timeline.json')
.readAsStringSync()); .readAsStringSync());
final Map<String, List<int>> transitions = new Map<String, List<int>>.fromIterable( final Map<String, List<int>> transitions = <String, List<int>>{};
original.keys, for (String key in original.keys) {
key: (String key) => key.replaceAll('/', ''), transitions[key.replaceAll('/', '')] = original[key];
value: (String key) => original[key]); }
final Map<String, dynamic> summary = JSON.decode(file('${galleryDirectory.path}/build/transitions.timeline_summary.json').readAsStringSync()); final Map<String, dynamic> summary = JSON.decode(file('${galleryDirectory.path}/build/transitions.timeline_summary.json').readAsStringSync());
......
...@@ -240,11 +240,10 @@ class CompileTest { ...@@ -240,11 +240,10 @@ class CompileTest {
watch.stop(); watch.stop();
final RegExp metricExpression = new RegExp(r'([a-zA-Z]+)\(CodeSize\)\: (\d+)'); final RegExp metricExpression = new RegExp(r'([a-zA-Z]+)\(CodeSize\)\: (\d+)');
final Map<String, dynamic> metrics = new Map<String, dynamic>.fromIterable( final Map<String, dynamic> metrics = <String, dynamic>{};
metricExpression.allMatches(compileLog), for (Match m in metricExpression.allMatches(compileLog)) {
key: (Match m) => _sdkNameToMetricName(m.group(1)), metrics[_sdkNameToMetricName(m.group(1))] = int.parse(m.group(2));
value: (Match m) => int.parse(m.group(2)), }
);
metrics['aot_snapshot_compile_millis'] = watch.elapsedMilliseconds; metrics['aot_snapshot_compile_millis'] = watch.elapsedMilliseconds;
return metrics; return metrics;
......
...@@ -18,7 +18,7 @@ class _FlavorState extends State<Flavor> { ...@@ -18,7 +18,7 @@ class _FlavorState extends State<Flavor> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
const MethodChannel('flavor').invokeMethod('getFlavor').then((String flavor) { const MethodChannel('flavor').invokeMethod('getFlavor').then((Object flavor) {
setState(() { setState(() {
_flavor = flavor; _flavor = flavor;
}); });
......
...@@ -125,7 +125,7 @@ String _jsonToMap(dynamic json) { ...@@ -125,7 +125,7 @@ String _jsonToMap(dynamic json) {
if (json is Iterable) if (json is Iterable)
return 'const <dynamic>[${json.map(_jsonToMap).join(',')}]'; 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>{'); final StringBuffer buffer = new StringBuffer('const <String, dynamic>{');
json.forEach((String key, dynamic value) { json.forEach((String key, dynamic value) {
buffer.writeln(_jsonToMapEntry(key, value)); buffer.writeln(_jsonToMapEntry(key, value));
......
...@@ -149,17 +149,15 @@ class GalleryAppState extends State<GalleryApp> { ...@@ -149,17 +149,15 @@ class GalleryAppState extends State<GalleryApp> {
); );
} }
final Map<String, WidgetBuilder> _kRoutes = final Map<String, WidgetBuilder> _kRoutes = <String, WidgetBuilder>{};
new Map<String, WidgetBuilder>.fromIterable( for (GalleryItem item in kAllGalleryItems) {
// For a different example of how to set up an application routing table // For a different example of how to set up an application routing table
// using named routes, consider the example in the Navigator class documentation: // using named routes, consider the example in the Navigator class documentation:
// https://docs.flutter.io/flutter/widgets/Navigator-class.html // https://docs.flutter.io/flutter/widgets/Navigator-class.html
kAllGalleryItems, _kRoutes[item.routeName] = (BuildContext context) {
key: (GalleryItem item) => item.routeName, return _applyScaleFactor(item.buildRoute(context));
value: (GalleryItem item) { };
return (BuildContext context) => _applyScaleFactor(item.buildRoute(context)); }
},
);
return new MaterialApp( return new MaterialApp(
title: 'Flutter Gallery', title: 'Flutter Gallery',
......
...@@ -40,7 +40,7 @@ class _PlatformChannelState extends State<PlatformChannel> { ...@@ -40,7 +40,7 @@ class _PlatformChannelState extends State<PlatformChannel> {
eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError); eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError);
} }
void _onEvent(String event) { void _onEvent(Object event) {
setState(() { setState(() {
_chargingStatus = _chargingStatus =
"Battery status: ${event == 'charging' ? '' : 'dis'}charging."; "Battery status: ${event == 'charging' ? '' : 'dis'}charging.";
......
...@@ -40,7 +40,7 @@ class _PlatformChannelState extends State<PlatformChannel> { ...@@ -40,7 +40,7 @@ class _PlatformChannelState extends State<PlatformChannel> {
eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError); eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError);
} }
void _onEvent(String event) { void _onEvent(Object event) {
setState(() { setState(() {
_chargingStatus = _chargingStatus =
"Battery status: ${event == 'charging' ? '' : 'dis'}charging."; "Battery status: ${event == 'charging' ? '' : 'dis'}charging.";
......
...@@ -19,7 +19,7 @@ class StockStrings { ...@@ -19,7 +19,7 @@ class StockStrings {
static Future<StockStrings> load(Locale locale) { static Future<StockStrings> load(Locale locale) {
return initializeMessages(locale.toString()) return initializeMessages(locale.toString())
.then((Null _) { .then((Object _) {
return new StockStrings(locale); return new StockStrings(locale);
}); });
} }
......
...@@ -459,7 +459,8 @@ abstract class WidgetsBinding extends BindingBase with SchedulerBinding, Gesture ...@@ -459,7 +459,8 @@ abstract class WidgetsBinding extends BindingBase with SchedulerBinding, Gesture
observer.didHaveMemoryPressure(); 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']; final String type = message['type'];
switch (type) { switch (type) {
case 'memoryPressure': case 'memoryPressure':
......
...@@ -300,11 +300,12 @@ class _TableElement extends RenderObjectElement { ...@@ -300,11 +300,12 @@ class _TableElement extends RenderObjectElement {
void update(Table newWidget) { void update(Table newWidget) {
assert(!_debugWillReattachChildren); assert(!_debugWillReattachChildren);
assert(() { _debugWillReattachChildren = true; return true; }()); assert(() { _debugWillReattachChildren = true; return true; }());
final Map<LocalKey, List<Element>> oldKeyedRows = new Map<LocalKey, List<Element>>.fromIterable( final Map<LocalKey, List<Element>> oldKeyedRows = <LocalKey, List<Element>>{};
_children.where((_TableElementRow row) => row.key != null), for (_TableElementRow row in _children) {
key: (_TableElementRow row) => row.key, if (row.key != null) {
value: (_TableElementRow row) => row.children oldKeyedRows[row.key] = row.children;
); }
}
final Iterator<_TableElementRow> oldUnkeyedRows = _children.where((_TableElementRow row) => row.key == null).iterator; final Iterator<_TableElementRow> oldUnkeyedRows = _children.where((_TableElementRow row) => row.key == null).iterator;
final List<_TableElementRow> newChildren = <_TableElementRow>[]; final List<_TableElementRow> newChildren = <_TableElementRow>[];
final Set<List<Element>> taken = new Set<List<Element>>(); final Set<List<Element>> taken = new Set<List<Element>>();
......
...@@ -12,7 +12,8 @@ void main() { ...@@ -12,7 +12,8 @@ void main() {
test('Semantic announcement', () async { test('Semantic announcement', () async {
final List<Map<String, dynamic>> log = <Map<String, dynamic>>[]; 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); 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