Commit 53fc96da authored by Jacob Richman's avatar Jacob Richman Committed by Adam Barth

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
parent 82f887de
...@@ -90,7 +90,7 @@ class OverlayGeometryApp extends StatefulWidget { ...@@ -90,7 +90,7 @@ class OverlayGeometryApp extends StatefulWidget {
OverlayGeometryAppState createState() => new OverlayGeometryAppState(); OverlayGeometryAppState createState() => new OverlayGeometryAppState();
} }
typedef void CardTapCallback(Key targetKey, Point globalPosition); typedef void CardTapCallback(GlobalKey targetKey, Point globalPosition);
class CardBuilder extends LazyBlockDelegate { class CardBuilder extends LazyBlockDelegate {
CardBuilder({ this.cardModels, this.onTapUp }); CardBuilder({ this.cardModels, this.onTapUp });
......
...@@ -27,11 +27,12 @@ abstract class Notification { ...@@ -27,11 +27,12 @@ abstract class Notification {
@protected @protected
@mustCallSuper @mustCallSuper
bool visitAncestor(Element element) { bool visitAncestor(Element element) {
if (element is StatelessElement && if (element is StatelessElement) {
element.widget is NotificationListener<Notification>) { StatelessWidget widget = element.widget;
final NotificationListener<Notification> widget = element.widget; if (widget is NotificationListener<Notification>) {
if (widget._dispatch(this, element)) // that function checks the type dynamically if (widget._dispatch(this, element)) // that function checks the type dynamically
return false; return false;
}
} }
return true; return true;
} }
......
...@@ -48,7 +48,7 @@ class Scroll extends CommandWithTarget { ...@@ -48,7 +48,7 @@ class Scroll extends CommandWithTarget {
) : super(finder); ) : super(finder);
/// Deserializes this command from JSON generated by [serialize]. /// 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.dx = double.parse(json['dx']),
this.dy = double.parse(json['dy']), this.dy = double.parse(json['dy']),
this.duration = new Duration(microseconds: int.parse(json['duration'])), this.duration = new Duration(microseconds: int.parse(json['duration'])),
...@@ -98,7 +98,7 @@ class ScrollIntoView extends CommandWithTarget { ...@@ -98,7 +98,7 @@ class ScrollIntoView extends CommandWithTarget {
ScrollIntoView(SerializableFinder finder) : super(finder); ScrollIntoView(SerializableFinder finder) : super(finder);
/// Deserializes this command from JSON generated by [serialize]. /// Deserializes this command from JSON generated by [serialize].
ScrollIntoView.deserialize(Map<String, dynamic> json) ScrollIntoView.deserialize(Map<String, String> json)
: super.deserialize(json); : super.deserialize(json);
// This is here just to be clear that this command isn't adding any extra // This is here just to be clear that this command isn't adding any extra
......
...@@ -20,7 +20,7 @@ class SetInputText extends CommandWithTarget { ...@@ -20,7 +20,7 @@ class SetInputText extends CommandWithTarget {
final String text; final String text;
/// Deserializes this command from JSON generated by [serialize]. /// Deserializes this command from JSON generated by [serialize].
SetInputText.deserialize(Map<String, dynamic> json) SetInputText.deserialize(Map<String, String> json)
: this.text = json['text'], : this.text = json['text'],
super.deserialize(json); super.deserialize(json);
...@@ -55,7 +55,7 @@ class SubmitInputText extends CommandWithTarget { ...@@ -55,7 +55,7 @@ class SubmitInputText extends CommandWithTarget {
SubmitInputText(SerializableFinder finder) : super(finder); SubmitInputText(SerializableFinder finder) : super(finder);
/// Deserializes this command from JSON generated by [serialize]. /// Deserializes this command from JSON generated by [serialize].
SubmitInputText.deserialize(Map<String, dynamic> json) SubmitInputText.deserialize(Map<String, String> json)
: super.deserialize(json); : super.deserialize(json);
} }
......
...@@ -40,7 +40,7 @@ class CoverageCollector { ...@@ -40,7 +40,7 @@ class CoverageCollector {
}); });
printTrace('pid $pid (port $port): collecting coverage data...'); 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..." }'); printTrace('pid $pid (port $port): ${ exitCode != null ? "process terminated prematurely with exit code $exitCode; aborting" : "collected coverage data; merging..." }');
if (exitCode != null) if (exitCode != null)
throw new Exception('Failed to collect coverage, process terminated prematurely.'); throw new Exception('Failed to collect coverage, process terminated prematurely.');
......
...@@ -147,7 +147,7 @@ void _upgradeCollection(dynamic collection, ...@@ -147,7 +147,7 @@ void _upgradeCollection(dynamic collection,
if (collection is ServiceMap) { if (collection is ServiceMap) {
return; return;
} }
if (collection is Map) { if (collection is Map<String, dynamic>) {
_upgradeMap(collection, owner); _upgradeMap(collection, owner);
} else if (collection is List) { } else if (collection is List) {
_upgradeList(collection, owner); _upgradeList(collection, owner);
...@@ -156,11 +156,11 @@ void _upgradeCollection(dynamic collection, ...@@ -156,11 +156,11 @@ void _upgradeCollection(dynamic collection,
void _upgradeMap(Map<String, dynamic> map, ServiceObjectOwner owner) { void _upgradeMap(Map<String, dynamic> map, ServiceObjectOwner owner) {
map.forEach((String k, dynamic v) { 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); map[k] = owner.getFromMap(v);
} else if (v is List) { } else if (v is List) {
_upgradeList(v, owner); _upgradeList(v, owner);
} else if (v is Map) { } else if (v is Map<String, dynamic>) {
_upgradeMap(v, owner); _upgradeMap(v, owner);
} }
}); });
...@@ -169,11 +169,11 @@ void _upgradeMap(Map<String, dynamic> map, ServiceObjectOwner owner) { ...@@ -169,11 +169,11 @@ void _upgradeMap(Map<String, dynamic> map, ServiceObjectOwner owner) {
void _upgradeList(List<dynamic> list, ServiceObjectOwner owner) { void _upgradeList(List<dynamic> list, ServiceObjectOwner owner) {
for (int i = 0; i < list.length; i++) { for (int i = 0; i < list.length; i++) {
dynamic v = list[i]; dynamic v = list[i];
if ((v is Map) && _isServiceMap(v)) { if ((v is Map<String, dynamic>) && _isServiceMap(v)) {
list[i] = owner.getFromMap(v); list[i] = owner.getFromMap(v);
} else if (v is List) { } else if (v is List) {
_upgradeList(v, owner); _upgradeList(v, owner);
} else if (v is Map) { } else if (v is Map<String, dynamic>) {
_upgradeMap(v, owner); _upgradeMap(v, owner);
} }
} }
...@@ -920,9 +920,9 @@ class ServiceMap extends ServiceObject implements Map<String, dynamic> { ...@@ -920,9 +920,9 @@ class ServiceMap extends ServiceObject implements Map<String, dynamic> {
@override @override
bool containsKey(Object k) => _map.containsKey(k); bool containsKey(Object k) => _map.containsKey(k);
@override @override
void forEach(Function f) => _map.forEach(f); void forEach(void f(String key, dynamic value)) => _map.forEach(f);
@override @override
dynamic putIfAbsent(String key, Function ifAbsent) => _map.putIfAbsent(key, ifAbsent); dynamic putIfAbsent(String key, dynamic ifAbsent()) => _map.putIfAbsent(key, ifAbsent);
@override @override
void remove(Object key) => _map.remove(key); void remove(Object key) => _map.remove(key);
@override @override
......
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