equal_elements_in_const_set
Two elements in a constant set literal can't be equal.
Description
#The analyzer produces this diagnostic when two elements in a constant set literal have the same value. The set can only contain each value once, which means that one of the values is unnecessary.
Example
#The following code produces this diagnostic because the string 'a'
is specified twice:
const Set<String> set = {'a', 'a'};
Common fixes
#Remove one of the duplicate values:
const Set<String> set = {'a'};
Note that literal sets preserve the order of their elements, so the choice of which element to remove might affect the order in which elements are returned by an iterator.
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.