DeepSource has joined Harness. Learn more
Dart Analyze logoDart Analyze/
DRT-W1543

Spread elements in list or set literals must implement 'Iterable'DRT-W1543

Major severityMajor
Bug Risk categoryBug Risk

The analyzer produces this diagnostic when the static type of the expression of a spread element that appears in either a list literal or a set literal doesn't implement the type Iterable.

Example

The following code produces this diagnostic:

var m = <String, int>{'a': 0, 'b': 1};
var s = <String>{...m};

Common fixes

The most common fix is to replace the expression with one that produces an iterable object:

var m = <String, int>{'a': 0, 'b': 1};
var s = <String>{...m.keys};