enable the avoid_dynamic_calls lint (#72)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 120bee4..30fdf91 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
## 1.0.1-dev
- Use `package:lints` for analysis.
- Populate the pubspec `repository` field.
+- Enable the `avoid_dynamic_calls` lint.
## 1.0.0
- Migrate to null safety.
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 2de85d5..8051c3b 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -3,3 +3,7 @@
analyzer:
errors:
deprecated_member_use_from_same_package: ignore
+
+linter:
+ rules:
+ - avoid_dynamic_calls
diff --git a/lib/forwarder.dart b/lib/forwarder.dart
index c53c36f..16a1ac0 100644
--- a/lib/forwarder.dart
+++ b/lib/forwarder.dart
@@ -45,7 +45,7 @@
}
Future _onClientDataHandler(String data) async {
- var json = jsonDecode(data);
+ var json = jsonDecode(data) as Map<String, dynamic>;
var response = {'id': json['id']};
_log.info('Forwarding to debugger: $data');
try {
diff --git a/lib/src/dom.dart b/lib/src/dom.dart
index bc56adb..7c5433f 100644
--- a/lib/src/dom.dart
+++ b/lib/src/dom.dart
@@ -27,33 +27,24 @@
Future<void> hideHighlight() => sendCommand('DOM.hideHighlight');
- Future<void> highlightNode(int nodeId,
- {Rgba? borderColor,
- Rgba? contentColor,
- Rgba? marginColor,
- Rgba? paddingColor,
- bool? showInfo}) {
- var params = <String, dynamic>{'nodeId': nodeId, 'highlightConfig': {}};
-
- if (borderColor != null) {
- params['highlightConfig']['borderColor'] = borderColor;
- }
-
- if (contentColor != null) {
- params['highlightConfig']['contentColor'] = contentColor;
- }
-
- if (marginColor != null) {
- params['highlightConfig']['marginColor'] = marginColor;
- }
-
- if (paddingColor != null) {
- params['highlightConfig']['paddingColor'] = paddingColor;
- }
-
- if (showInfo != null) {
- params['highlightConfig']['showInfo'] = showInfo;
- }
+ Future<void> highlightNode(
+ int nodeId, {
+ Rgba? borderColor,
+ Rgba? contentColor,
+ Rgba? marginColor,
+ Rgba? paddingColor,
+ bool? showInfo,
+ }) {
+ var params = <String, dynamic>{
+ 'nodeId': nodeId,
+ 'highlightConfig': <String, dynamic>{
+ if (borderColor != null) 'borderColor': borderColor,
+ if (contentColor != null) 'contentColor': contentColor,
+ if (marginColor != null) 'marginColor': marginColor,
+ if (paddingColor != null) 'paddingColor': paddingColor,
+ if (showInfo != null) 'showInfo': showInfo,
+ },
+ };
return sendCommand('DOM.highlightNode', params: params);
}
diff --git a/lib/webkit_inspection_protocol.dart b/lib/webkit_inspection_protocol.dart
index 25b7e8a..1b1a51a 100644
--- a/lib/webkit_inspection_protocol.dart
+++ b/lib/webkit_inspection_protocol.dart
@@ -145,7 +145,7 @@
final StreamController<String> _onReceive =
StreamController.broadcast(sync: true);
- final Map _completers = <int, Completer<WipResponse>>{};
+ final Map<int, Completer<WipResponse>> _completers = {};
final _closeController = StreamController<WipConnection>.broadcast();
final _notificationController = StreamController<WipEvent>.broadcast();
@@ -185,7 +185,7 @@
if (params != null) {
json['params'] = params;
}
- _completers[json['id']] = completer;
+ _completers[json['id'] as int] = completer;
String message = jsonEncode(json);
_ws.add(message);
_onSend.add(message);
@@ -197,7 +197,7 @@
}
void _handleResponse(Map<String, dynamic> event) {
- var completer = _completers.remove(event['id']);
+ var completer = _completers.remove(event['id'])!;
if (event.containsKey('error')) {
completer.completeError(WipError(event));
diff --git a/test/console_test.dart b/test/console_test.dart
index 94eaf1a..e4f68a0 100644
--- a/test/console_test.dart
+++ b/test/console_test.dart
@@ -15,7 +15,7 @@
group('WipConsole', () {
WipConsole? console; // ignore: deprecated_member_use
List<ConsoleMessageEvent> events = [];
- var subs = [];
+ var subs = <StreamSubscription>[];
Future checkMessages(int expectedCount) async {
// make sure all messages have been delivered