conflicting_ type_ variable_ and_ container
'{0}' can't be used to name both a type parameter and the class in which the type parameter is defined.
'{0}' can't be used to name both a type parameter and the enum in which the type parameter is defined.
'{0}' can't be used to name both a type parameter and the extension in which the type parameter is defined.
'{0}' can't be used to name both a type parameter and the extension type in which the type parameter is defined.
'{0}' can't be used to name both a type parameter and the mixin in which the type parameter is defined.
Description
#The analyzer produces this diagnostic when a class, mixin, or extension declaration declares a type parameter with the same name as the class, mixin, or extension that declares it.
Example
#
The following code produces this diagnostic because the type parameter
C
has the same name as the class
C
of which it's a part:
class C<C> {}
Common fixes
#Rename either the type parameter, or the class, mixin, or extension:
class C<T> {}
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-4. View source or report an issue.