conflicting_ generic_ interfaces
Details about the 'conflicting_generic_interfaces' diagnostic produced by the Dart analyzer.
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 implements
B), 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 {}
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.