expected_one_list_pattern_type_arguments
List patterns require one type argument or none, but {0} found.
Description
#The analyzer produces this diagnostic when a list pattern has more than one type argument. List patterns can have either zero type arguments or one type argument, but can't have more than one.
Example
#The following code produces this diagnostic because the list pattern ([0]
) has two type arguments:
void f(Object x) {
if (x case <int, int>[0]) {}
}
Common fixes
#Remove all but one of the type arguments:
void f(Object x) {
if (x case <int>[0]) {}
}
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.