conflicting_ generic_ interfaces
The {0} '{1}' can't implement both '{2}' and '{3}' because the type arguments are different.
Description
#The analyzer produces this diagnostic when a class attempts to implement a generic interface multiple times, and the values of the type arguments aren't the same.
Example
#
The following code produces this diagnostic because
C
is defined to
implement both
I<int>
(because it extends
A
) and
I<String>
(because
it implementsB
), but
int
and
String
aren't the same type:
class I<T> {}
class A implements I<int> {}
class B implements I<String> {}
class C extends A implements B {}
Common fixes
#
Rework the type hierarchy to avoid this situation. For example, you might
make one or both of the inherited types generic so that
C
can specify the
same type for both type arguments:
class I<T> {}
class A<S> implements I<S> {}
class B implements I<String> {}
class C extends A<String> implements B {}
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.