Literals get type annotations.

As per the recent fix to the `always_specify_types` lint (https://github.com/dart-lang/linter/issues/199), literal maps and lists are now expected to be explicitly typed.

Running that lint on the repo identifies quite a few spots to update.  This focuses on `flutter_driver` and `flutter_sprites` (somewhat arbitrarily) but the changes are fairly representative.

Note there are a number of places where I made a quick judgement on how specific to make the types.  Feedback on those is welcome.  (Especially as we move forward with more.)
This commit is contained in:
pq
2016-05-04 09:18:31 -07:00
parent 1e093701b7
commit bcede8dffb
11 changed files with 54 additions and 54 deletions

View File

@@ -252,7 +252,7 @@ class FlutterDriver {
Future<Null> startTracing({List<TracingCategory> categories: _defaultCategories}) async {
assert(categories != null && categories.length > 0);
try {
await _peer.sendRequest(_kSetVMTimelineFlagsMethod, {
await _peer.sendRequest(_kSetVMTimelineFlagsMethod, <String, String>{
'recordedStreams': _tracingCategoriesToString(categories)
});
return null;
@@ -268,7 +268,7 @@ class FlutterDriver {
/// Stops recording performance traces and downloads the timeline.
Future<Timeline> stopTracingAndDownloadTimeline() async {
try {
await _peer.sendRequest(_kSetVMTimelineFlagsMethod, {'recordedStreams': '[]'});
await _peer.sendRequest(_kSetVMTimelineFlagsMethod, <String, String>{'recordedStreams': '[]'});
return new Timeline.fromJson(await _peer.sendRequest(_kGetVMTimelineMethod));
} catch(error, stackTrace) {
throw new DriverError(

View File

@@ -91,7 +91,7 @@ abstract class SerializableFinder {
throw new DriverError('Unsupported search specification type $finderType');
}
Map<String, String> serialize() => {
Map<String, String> serialize() => <String, String>{
'finderType': finderType,
};
}
@@ -107,7 +107,7 @@ class ByTooltipMessage extends SerializableFinder {
final String text;
@override
Map<String, String> serialize() => super.serialize()..addAll({
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
'text': text,
});
@@ -126,7 +126,7 @@ class ByText extends SerializableFinder {
final String text;
@override
Map<String, String> serialize() => super.serialize()..addAll({
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
'text': text,
});
@@ -160,7 +160,7 @@ class ByValueKey extends SerializableFinder {
final String keyValueType;
@override
Map<String, String> serialize() => super.serialize()..addAll({
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
'keyValueString': keyValueString,
'keyValueType': keyValueType,
});
@@ -205,7 +205,7 @@ class GetTextResult extends Result {
}
@override
Map<String, dynamic> toJson() => {
Map<String, dynamic> toJson() => <String, String>{
'text': text,
};
}

View File

@@ -25,7 +25,7 @@ class TapResult extends Result {
}
@override
Map<String, dynamic> toJson() => {};
Map<String, dynamic> toJson() => <String, dynamic>{};
}
@@ -65,7 +65,7 @@ class Scroll extends CommandWithTarget {
final int frequency;
@override
Map<String, String> serialize() => super.serialize()..addAll({
Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
'dx': '$dx',
'dy': '$dy',
'duration': '${duration.inMicroseconds}',
@@ -92,5 +92,5 @@ class ScrollResult extends Result {
}
@override
Map<String, dynamic> toJson() => {};
Map<String, dynamic> toJson() => <String, dynamic>{};
}

View File

@@ -13,7 +13,7 @@ class GetHealth implements Command {
static GetHealth deserialize(Map<String, String> json) => new GetHealth();
@override
Map<String, String> serialize() => const {};
Map<String, String> serialize() => const <String, String>{};
}
/// Application health status.
@@ -42,7 +42,7 @@ class Health extends Result {
final HealthStatus status;
@override
Map<String, dynamic> toJson() => {
Map<String, dynamic> toJson() => <String, dynamic>{
'status': _healthStatusIndex.toSimpleName(status)
};
}

View File

@@ -6,7 +6,7 @@ import 'package:matcher/matcher.dart';
/// Matches [value] against the [matcher].
MatchResult match(dynamic value, Matcher matcher) {
Map<dynamic, dynamic> matchState = {};
Map<dynamic, dynamic> matchState = <dynamic, dynamic>{};
if (matcher.matches(value, matchState)) {
return new MatchResult._matched();
} else {