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:
@@ -156,12 +156,12 @@ class WebFlutterDriver extends FlutterDriver {
|
||||
final List<Map<String, dynamic>> events = <Map<String, dynamic>>[];
|
||||
for (final async_io.LogEntry entry in await _connection.logs.toList()) {
|
||||
if (_startTime.isBefore(entry.timestamp)) {
|
||||
final Map<String, dynamic> data = jsonDecode(entry.message!)['message'] as Map<String, dynamic>;
|
||||
final Map<String, dynamic> data = (jsonDecode(entry.message!) as Map<String, dynamic>)['message'] as Map<String, dynamic>;
|
||||
if (data['method'] == 'Tracing.dataCollected') {
|
||||
// 'ts' data collected from Chrome is in double format, conversion needed
|
||||
try {
|
||||
data['params']['ts'] =
|
||||
double.parse(data['params']['ts'].toString()).toInt();
|
||||
final Map<String, dynamic> params = data['params'] as Map<String, dynamic>;
|
||||
params['ts'] = double.parse(params['ts'].toString()).toInt();
|
||||
} on FormatException catch (_) {
|
||||
// data is corrupted, skip
|
||||
continue;
|
||||
|
||||
@@ -968,16 +968,16 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
/// This function will verify the format of the script
|
||||
/// and return the actual script.
|
||||
/// script will be in the following format:
|
||||
// This function will verify the format of the script and return the actual
|
||||
// script. The script will be in the following format:
|
||||
// window.flutterDriver('[actual script]')
|
||||
String? _checkAndEncode(dynamic script) {
|
||||
String _checkAndEncode(dynamic script) {
|
||||
expect(script, isA<String>());
|
||||
expect(script.startsWith(_kWebScriptPrefix), isTrue);
|
||||
expect(script.endsWith(_kWebScriptSuffix), isTrue);
|
||||
final String scriptString = script as String;
|
||||
expect(scriptString.startsWith(_kWebScriptPrefix), isTrue);
|
||||
expect(scriptString.endsWith(_kWebScriptSuffix), isTrue);
|
||||
// Strip prefix and suffix
|
||||
return script.substring(_kWebScriptPrefix.length, script.length - 2) as String?;
|
||||
return scriptString.substring(_kWebScriptPrefix.length, script.length - 2);
|
||||
}
|
||||
|
||||
vms.Response? makeFakeResponse(
|
||||
@@ -999,7 +999,7 @@ class FakeFlutterWebConnection extends Fake implements FlutterWebConnection {
|
||||
@override
|
||||
Future<dynamic> sendCommand(String script, Duration? duration) async {
|
||||
commandLog.add('$script $duration');
|
||||
final Map<String, dynamic> decoded = jsonDecode(_checkAndEncode(script)!) as Map<String, dynamic>;
|
||||
final Map<String, dynamic> decoded = jsonDecode(_checkAndEncode(script)) as Map<String, dynamic>;
|
||||
final dynamic response = responses[decoded['command']];
|
||||
assert(response != null, 'Missing ${decoded['command']} in responses.');
|
||||
return response;
|
||||
|
||||
Reference in New Issue
Block a user