Fix several Dart 2 issues in the flutter_driver. (#14749)

* All lists produced by JSON parsing are List<dynamic>. If more
speficic type is required then they need to be explicitly cast, e.g.
using castFrom helper;
* Function of type (ByText) -> Finder is not a subtype of
(SerializableFinder) -> Finder because ByText is in the contravariant
position;
* In Dart 2 typed(any) should be used instead of any in mockito based
tests.
This commit is contained in:
Vyacheslav Egorov
2018-02-16 18:01:54 +01:00
committed by GitHub
parent 2a6ed0a869
commit aa7e9637ac
3 changed files with 16 additions and 15 deletions

View File

@@ -122,12 +122,13 @@ class TimelineEvent {
}
List<TimelineEvent> _parseEvents(Map<String, dynamic> json) {
final List<Map<String, dynamic>> jsonEvents = json['traceEvents'];
final List<dynamic> jsonEvents = json['traceEvents'];
if (jsonEvents == null)
return null;
return jsonEvents
// TODO(vegorov) use instance method version of castFrom when it is available.
return Iterable.castFrom<dynamic, Map<String, dynamic>>(jsonEvents)
.map((Map<String, dynamic> eventJson) => new TimelineEvent(eventJson))
.toList();
}

View File

@@ -125,10 +125,10 @@ class FlutterDriverExtension {
});
_finders.addAll(<String, FinderConstructor>{
'ByText': _createByTextFinder,
'ByTooltipMessage': _createByTooltipMessageFinder,
'ByValueKey': _createByValueKeyFinder,
'ByType': _createByTypeFinder,
'ByText': (SerializableFinder finder) => _createByTextFinder(finder),
'ByTooltipMessage': (SerializableFinder finder) => _createByTooltipMessageFinder(finder),
'ByValueKey': (SerializableFinder finder) => _createByValueKeyFinder(finder),
'ByType': (SerializableFinder finder) => _createByTypeFinder(finder),
});
}