How to delete duplicates in a dart List? list.distinct()?

后端 未结 11 2124
夕颜
夕颜 2020-12-01 05:21

How do i delete duplicates from a list without fooling around with a set? Is there something like list.distinct()? or list.unique()?

void main() {
  print(\"         


        
11条回答
  •  孤独总比滥情好
    2020-12-01 05:39

    try the following

    List duplicates = ["a","c","a"];
    
    duplicates = duplicates.toSet().toList();
    

    check the Dartpad link - https://dartpad.dev/4d3a724429bbd605f4682b7da253a16e

提交回复
热议问题