expression_in_map
Expressions can't be used in a map literal.
Description
#The analyzer produces this diagnostic when the analyzer finds an expression, rather than a map entry, in what appears to be a map literal.
Example
#The following code produces this diagnostic:
dart
var map = <String, int>{'a': 0, 'b': 1, 'c'};
Common fixes
#If the expression is intended to compute either a key or a value in an entry, fix the issue by replacing the expression with the key or the value. For example:
dart
var map = <String, int>{'a': 0, 'b': 1, 'c': 2};
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.