expected_two_map_pattern_type_arguments
Map patterns require two type arguments or none, but {0} found.
Description
#The analyzer produces this diagnostic when a map pattern has either one type argument or more than two type arguments. Map patterns can have either two type arguments or zero type arguments, but can't have any other number.
Example
#The following code produces this diagnostic because the map pattern (<int>{}
) has one type argument:
dart
void f(Object x) {
if (x case <int>{0: _}) {}
}
Common fixes
#Add or remove type arguments until there are two, or none:
dart
void f(Object x) {
if (x case <int, int>{0: _}) {}
}
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.