not_map_spread
Details about the 'not_map_spread' diagnostic produced by the Dart analyzer.
Spread elements in map literals must implement 'Map'.
Description
#
The analyzer produces this diagnostic when the static type of the
expression of a spread element that appears in a map literal doesn't
implement the type Map.
Example
#The following code produces this diagnostic because l isn't a Map:
dart
var l = <String>['a', 'b'];
var m = <int, String>{...l};
Common fixes
#The most common fix is to replace the expression with one that produces a map:
dart
var l = <String>['a', 'b'];
var m = <int, String>{...l.asMap()};
Was this page's content helpful?
除非另有说明,文档之所提及适用于 Dart 3.10.3 版本报告页面问题.