Skip to content

Instantly share code, notes, and snippets.

@IsmailAlamKhan
Created June 14, 2022 12:44
Show Gist options
  • Save IsmailAlamKhan/428c9715671b062362d0eaab3fea2537 to your computer and use it in GitHub Desktop.
Save IsmailAlamKhan/428c9715671b062362d0eaab3fea2537 to your computer and use it in GitHub Desktop.
final duplicatedList = <String>[
'Tayfer',
'Ismail',
'RoyalCoder',
'Tayfer',
'RoyalCoder',
'Tayfer',
'FatherRussia',
'RoyalCoder',
'Sdk',
'FatherRussia',
'Sdk',
'Tomic'
'Sdk',
];
extension DuplicateCountOnList<T> on List<T> {
int get duplicateCount {
final tempList = <T>[];
for (final item in this) {
if (!tempList.contains(item)) {
tempList.add(item);
}
}
return tempList.length;
}
}
void main() {
print(duplicatedList.duplicateCount);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment