type_argument_not_matching_bounds
'{0}' doesn't conform to the bound '{2}' of the type parameter '{1}'.
Description
#The analyzer produces this diagnostic when a type argument isn't the same as or a subclass of the bounds of the corresponding type parameter.
Example
#The following code produces this diagnostic because String
isn't a subclass of num
:
dart
class A<E extends num> {}
var a = A<String>();
Common fixes
#Change the type argument to be a subclass of the bounds:
dart
class A<E extends num> {}
var a = A<int>();
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.