reverse function

String reverse(
  1. String string
)

Returns a string with reversed order of characters.

Example: print(reverse("hello")); => olleh

Implementation

String reverse(String string) {
  if (string.length < 2) {
    return string;
  }

  final characters = Characters(string);
  return characters.toList().reversed.join();
}