How to compare string with case insensitivity in Dart

1 Answer

0 votes
bool CompareStringIgnoreCase(String string1, String string2) {
    return string1.toLowerCase() == string2.toLowerCase();
}

void main() {
    print(CompareStringIgnoreCase("dart", "DART"));
    
    print(CompareStringIgnoreCase("dart", "DARTT"));
    
    print(CompareStringIgnoreCase("24562", "24562"));
}




/*
run:

true
false
true

*/

 



answered Oct 12, 2022 by avibootz

Related questions

1 answer 116 views
116 views asked Oct 21, 2022 by avibootz
1 answer 182 views
3 answers 167 views
167 views asked Oct 21, 2022 by avibootz
1 answer 169 views
1 answer 209 views
1 answer 125 views
...