non_covariant_type_parameter_position_in_representation_type
Details about the 'non_covariant_type_parameter_position_in_representation_type' diagnostic produced by the Dart analyzer.
An extension type parameter can't be used in a non-covariant position of its representation type.
Description
#The analyzer produces this diagnostic when a type parameter of an extension type is used in a non-covariant position in the representation type of that extension type.
Example
#
The following code produces this diagnostic because the type parameter T
is used as a parameter type in the function type void Function(T), and
parameters are not covariant:
extension type A<T>(void Function(T) f) {}
Common fixes
#Remove the use of the type parameter:
extension type A(void Function(String) f) {}
除非另有说明,文档之所提及适用于 Dart 3.10.3 版本报告页面问题.