Turn on avoid_dynamic_calls lint, except packages/flutter tests, make appropriate changes. (#84476)

This adds avoid_dynamic_calls to the list of lints, and fixes all instances where it was violated.

Importantly, this lint is NOT turned on for flutter/packages/test, because those changes are happening in another PR: #84478
This commit is contained in:
Greg Spencer
2021-06-14 14:16:57 -07:00
committed by GitHub
parent acd68cf47b
commit 88f3811055
56 changed files with 331 additions and 235 deletions

View File

@@ -866,7 +866,7 @@ class _HasGoodToStringDeep extends Matcher {
@override
bool matches(dynamic object, Map<dynamic, dynamic> matchState) {
final List<String> issues = <String>[];
String description = object.toStringDeep() as String;
String description = object.toStringDeep() as String; // ignore: avoid_dynamic_calls
if (description.endsWith('\n')) {
// Trim off trailing \n as the remaining calculations assume
// the description does not end with a trailing \n.
@@ -904,7 +904,7 @@ class _HasGoodToStringDeep extends Matcher {
const String prefixOtherLines = 'PREFIX_OTHER_LINES_';
final List<String> prefixIssues = <String>[];
String descriptionWithPrefixes =
object.toStringDeep(prefixLineOne: prefixLineOne, prefixOtherLines: prefixOtherLines) as String;
object.toStringDeep(prefixLineOne: prefixLineOne, prefixOtherLines: prefixOtherLines) as String; // ignore: avoid_dynamic_calls
if (descriptionWithPrefixes.endsWith('\n')) {
// Trim off trailing \n as the remaining calculations assume
// the description does not end with a trailing \n.
@@ -1875,7 +1875,7 @@ class _MatchesSemanticsData extends Matcher {
bool allMatched = true;
if (children != null) {
int i = 0;
node.visitChildren((SemanticsNode child) {
(node as SemanticsNode).visitChildren((SemanticsNode child) {
allMatched = children![i].matches(child, matchState) && allMatched;
i += 1;
return allMatched;

View File

@@ -119,8 +119,9 @@ class TestTextInput {
log.add(methodCall);
switch (methodCall.method) {
case 'TextInput.setClient':
_client = methodCall.arguments[0] as int;
setClientArgs = methodCall.arguments[1] as Map<String, dynamic>;
final List<dynamic> arguments = methodCall.arguments as List<dynamic>;
_client = arguments[0] as int;
setClientArgs = arguments[1] as Map<String, dynamic>;
break;
case 'TextInput.updateConfig':
setClientArgs = methodCall.arguments as Map<String, dynamic>;

View File

@@ -11,6 +11,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
test('TestWindow can handle new methods without breaking', () {
final dynamic testWindow = TestWindow(window: ui.window);
// ignore: avoid_dynamic_calls
expect(testWindow.someNewProperty, null);
});