Created
June 14, 2022 12:44
-
-
Save IsmailAlamKhan/428c9715671b062362d0eaab3fea2537 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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