random method

String random()

Returns a random character from this string.

The string is split into characters, shuffled, then the first one is returned.

Example:

"hello".random(); // could return "h", "e", "l", etc.

Implementation

String random() {
  final splitted = split('');
  splitted.shuffle();
  return splitted.first;
}