compare method

int compare(
  1. String? str1,
  2. String? str2
)

比较两个字符串是否相同

Implementation

int compare(String? str1, String? str2) {
  if (str1 == null || str2 == null) {
    return str1 == null ? -1 : 1;
  }

  if (str1 == str2) {
    return 0;
  }

  return str1.compareTo(str2);
}