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 110 views
110 views asked Oct 21, 2022 by avibootz
1 answer 176 views
3 answers 162 views
162 views asked Oct 21, 2022 by avibootz
1 answer 165 views
1 answer 205 views
1 answer 120 views
...