reverse static method

String reverse(
  1. String? text
)

反转字符串

Implementation

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