avoid_dynamic_calls
Method invocation or property access on a 'dynamic' target.
Description
#The analyzer produces this diagnostic when a member of a class is accessed
on an expression whose type is dynamic
.
Example
#The following code produces this diagnostic because the getter length
is
being invoked on s
, which has the type dynamic
:
dart
void f(dynamic s) {
s.length;
}
Common fixes
#Provide enough type information that the expression has a type other than
dynamic
:
dart
void f(String s) {
s.length;
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。