See the question and my original answer on StackOverflow

You can use Google's own quiver strings package. It has a equalsIgnoreCase function. And here is its implementation:

When null is allowed:

bool equalsIgnoreCase(String? a, String? b) =>
    (a == null && b == null) ||
    (a != null && b != null && a.toLowerCase() == b.toLowerCase());

When null isn't allowed:

bool equalsIgnoreCase(String a, String b) => a.toLowerCase() == b.toLowerCase();