Small Flutter strong mode cleanup fixes. (#7825)

* Small Flutter strong mode cleanup fixes.

These are cases where strong mode down cast composite errors
generally indicated cases that would performance or correctness
issues if Flutter code was run in a strong mode VM.

* Fix Command API so that it is always in terms of Map<String,String>.

* Fix typedef
diff --git a/packages/flutter/lib/src/widgets/notification_listener.dart b/packages/flutter/lib/src/widgets/notification_listener.dart
index b1fddef..261d24e 100644
--- a/packages/flutter/lib/src/widgets/notification_listener.dart
+++ b/packages/flutter/lib/src/widgets/notification_listener.dart
@@ -27,11 +27,12 @@
   @protected
   @mustCallSuper
   bool visitAncestor(Element element) {
-    if (element is StatelessElement &&
-        element.widget is NotificationListener<Notification>) {
-      final NotificationListener<Notification> widget = element.widget;
-      if (widget._dispatch(this, element)) // that function checks the type dynamically
-        return false;
+    if (element is StatelessElement) {
+      StatelessWidget widget = element.widget;
+      if (widget is NotificationListener<Notification>) {
+        if (widget._dispatch(this, element)) // that function checks the type dynamically
+          return false;
+      }
     }
     return true;
   }
diff --git a/packages/flutter_driver/lib/src/gesture.dart b/packages/flutter_driver/lib/src/gesture.dart
index 6a2741c..04a8305 100644
--- a/packages/flutter_driver/lib/src/gesture.dart
+++ b/packages/flutter_driver/lib/src/gesture.dart
@@ -48,7 +48,7 @@
   ) : super(finder);
 
   /// Deserializes this command from JSON generated by [serialize].
-  Scroll.deserialize(Map<String, dynamic> json)
+  Scroll.deserialize(Map<String, String> json)
       : this.dx = double.parse(json['dx']),
         this.dy = double.parse(json['dy']),
         this.duration = new Duration(microseconds: int.parse(json['duration'])),
@@ -98,7 +98,7 @@
   ScrollIntoView(SerializableFinder finder) : super(finder);
 
   /// Deserializes this command from JSON generated by [serialize].
-  ScrollIntoView.deserialize(Map<String, dynamic> json)
+  ScrollIntoView.deserialize(Map<String, String> json)
       : super.deserialize(json);
 
   // This is here just to be clear that this command isn't adding any extra
diff --git a/packages/flutter_driver/lib/src/input.dart b/packages/flutter_driver/lib/src/input.dart
index e9dba23..519db97 100644
--- a/packages/flutter_driver/lib/src/input.dart
+++ b/packages/flutter_driver/lib/src/input.dart
@@ -20,7 +20,7 @@
   final String text;
 
   /// Deserializes this command from JSON generated by [serialize].
-  SetInputText.deserialize(Map<String, dynamic> json)
+  SetInputText.deserialize(Map<String, String> json)
       : this.text = json['text'],
         super.deserialize(json);
 
@@ -55,7 +55,7 @@
   SubmitInputText(SerializableFinder finder) : super(finder);
 
   /// Deserializes this command from JSON generated by [serialize].
-  SubmitInputText.deserialize(Map<String, dynamic> json)
+  SubmitInputText.deserialize(Map<String, String> json)
       : super.deserialize(json);
 }
 
diff --git a/packages/flutter_tools/lib/src/test/coverage_collector.dart b/packages/flutter_tools/lib/src/test/coverage_collector.dart
index 62e1a94..8e50368 100644
--- a/packages/flutter_tools/lib/src/test/coverage_collector.dart
+++ b/packages/flutter_tools/lib/src/test/coverage_collector.dart
@@ -40,7 +40,7 @@
     });
 
     printTrace('pid $pid (port $port): collecting coverage data...');
-    final Map<dynamic, dynamic> data = await collect(host.address, port, false, false);
+    final Map<String, dynamic> data = await collect(host.address, port, false, false);
     printTrace('pid $pid (port $port): ${ exitCode != null ? "process terminated prematurely with exit code $exitCode; aborting" : "collected coverage data; merging..." }');
     if (exitCode != null)
       throw new Exception('Failed to collect coverage, process terminated prematurely.');
diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart
index a7dd705..50c9a55 100644
--- a/packages/flutter_tools/lib/src/vmservice.dart
+++ b/packages/flutter_tools/lib/src/vmservice.dart
@@ -147,7 +147,7 @@
   if (collection is ServiceMap) {
     return;
   }
-  if (collection is Map) {
+  if (collection is Map<String, dynamic>) {
     _upgradeMap(collection, owner);
   } else if (collection is List) {
     _upgradeList(collection, owner);
@@ -156,11 +156,11 @@
 
 void _upgradeMap(Map<String, dynamic> map, ServiceObjectOwner owner) {
   map.forEach((String k, dynamic v) {
-    if ((v is Map) && _isServiceMap(v)) {
+    if ((v is Map<String, dynamic>) && _isServiceMap(v)) {
       map[k] = owner.getFromMap(v);
     } else if (v is List) {
       _upgradeList(v, owner);
-    } else if (v is Map) {
+    } else if (v is Map<String, dynamic>) {
       _upgradeMap(v, owner);
     }
   });
@@ -169,11 +169,11 @@
 void _upgradeList(List<dynamic> list, ServiceObjectOwner owner) {
   for (int i = 0; i < list.length; i++) {
     dynamic v = list[i];
-    if ((v is Map) && _isServiceMap(v)) {
+    if ((v is Map<String, dynamic>) && _isServiceMap(v)) {
       list[i] = owner.getFromMap(v);
     } else if (v is List) {
       _upgradeList(v, owner);
-    } else if (v is Map) {
+    } else if (v is Map<String, dynamic>) {
       _upgradeMap(v, owner);
     }
   }
@@ -920,9 +920,9 @@
   @override
   bool containsKey(Object k) => _map.containsKey(k);
   @override
-  void forEach(Function f) => _map.forEach(f);
+  void forEach(void f(String key, dynamic value)) => _map.forEach(f);
   @override
-  dynamic putIfAbsent(String key, Function ifAbsent) => _map.putIfAbsent(key, ifAbsent);
+  dynamic putIfAbsent(String key, dynamic ifAbsent()) => _map.putIfAbsent(key, ifAbsent);
   @override
   void remove(Object key) => _map.remove(key);
   @override