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 226 views
226 views asked Oct 21, 2022 by avibootz
1 answer 287 views
3 answers 330 views
330 views asked Oct 21, 2022 by avibootz
1 answer 266 views
1 answer 331 views
1 answer 252 views
...