avoid_ types_ as_ parameter_ names
The parameter name '{0}' matches a visible type name.
The type parameter name '{0}' matches a visible type name.
Description
#The analyzer produces this diagnostic when the name of a parameter in a parameter list is the same as a visible type (a type whose name is in scope).
This often indicates that the intended name of the parameter is missing, causing the name of the type to be used as the name of the parameter rather than the type of the parameter. Even when that's not the case (the name of the parameter is intentional), the name of the parameter will shadow the existing type, which can lead to bugs that are difficult to diagnose.
The analyzer also produces this diagnostic when the name of a type parameter in a type parameter list is the same as a type whose name is in scope. It is again recommended that the type parameter is renamed such that the error-prone shadowing is avoided.
Example
#
The following code produces this diagnostic because the function
f
has a
parameter named
int
, which shadows the type
int
from
dart:core
:
void f(int) {}
Common fixes
#If the parameter name is missing, then add a name for the parameter:
void f(int x) {}
If the parameter is intended to have an implicit type of
dynamic
, then
rename the parameter so that it doesn't shadow the name of any visible type:
void f(int_) {}
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.