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 132 views
132 views asked Oct 21, 2022 by avibootz
1 answer 191 views
3 answers 181 views
181 views asked Oct 21, 2022 by avibootz
1 answer 178 views
1 answer 218 views
1 answer 144 views
...