EN_raw_map_entry_not_in_map

  •                   Toolschevron_right
    
  •                   Diagnosticschevron_right
    
  •                   map_entry_not_in_map
    
                map_entry_not_in_map
    

Details about the 'map_entry_not_in_map' diagnostic produced by the Dart analyzer.

                more_vert
  •                       copyCopy link
    
  •                       bug_reportReport issue
    

Map entries can only be used in a map literal.

              Description

              #

              The analyzer produces this diagnostic when a map entry (a key/value pair)
              is found in a set literal.

              Example

              #

              The following code produces this diagnostic because the literal has a map
              entry even though it's a set literal:

                dart
var collection = <String>{'a': 'b'};
                content_copy

              Common fixes

              #

              If you intended for the collection to be a map, then change the code so
              that it is a map. In the previous example, you could do this by adding
              another type argument:

                dart
var collection = <String, String>{'a': 'b'};
                content_copy

              In other cases, you might need to change the explicit type from `Set` to
              `Map`.

              If you intended for the collection to be a set, then remove the map entry,
              possibly by replacing the colon with a comma if both values should be
              included in the set:

                dart
var collection = <String>{'a', 'b'};
                content_copy

Was this page's content helpful?

                    thumb_up
                    thumb_down

                Unless stated otherwise, the documentation on this site reflects Dart 3.13.3. Report an issue.