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.9.2. Page last updated on 2025-9-1. View source or report an issue.