How to compare String with case insensitivity, in Dart?

There’s no built in way to compare strings case-insensitive in dart (as @lrn answered).

If you only want to compare strings case-insensitive, I would go with declaring the following method somewhere in a common place:

bool equalsIgnoreCase(String? string1, String? string2) {
  return string1?.toLowerCase() == string2?.toLowerCase();
}

Example:

equalsIgnoreCase("ABC", "abc"); // -> true
equalsIgnoreCase("123" "abc");  // -> false
equalsIgnoreCase(null, "abc");  // -> false
equalsIgnoreCase(null, null);   // -> true

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)