reverse static method

String reverse(
  1. String? text
)

反转字符串

Implementation

static String reverse(String? text) {
  if (text == null || text.isBlank()) {
    return '';
  }
  StringBuffer sb = StringBuffer();
  for (int i = text.length - 1; i >= 0; i--) {
    var codeUnitAt = text.codeUnitAt(i);
    sb.writeCharCode(codeUnitAt);
  }
  return sb.toString();
}