conflicting_type_variable_and_member
'{0}' can't be used to name both a type parameter and a member in this class.
'{0}' can't be used to name both a type parameter and a member in this enum.
'{0}' can't be used to name both a type parameter and a member in this extension type.
'{0}' can't be used to name both a type parameter and a member in this extension.
'{0}' can't be used to name both a type parameter and a member in this mixin.
Description
#The analyzer produces this diagnostic when a class, mixin, or extension declaration declares a type parameter with the same name as one of the members of the class, mixin, or extension that declares it.
Example
#The following code produces this diagnostic because the type parameter T
has the same name as the field T
:
class C<T> {
int T = 0;
}
Common fixes
#Rename either the type parameter or the member with which it conflicts:
class C<T> {
int total = 0;
}
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.