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
:
void f(dynamic s) {
s.length;
}
Common fixes
#
Provide enough type information that the expression has a type other than
dynamic
:
void f(String s) {
s.length;
}
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-1. View source or report an issue.