shuffle method Null safety

String? shuffle()

Shuffles the given string characters.

Example

String foo1 = 'esentis'
String shuffled = foo.shuffle() // 'tsniees';

Implementation

String? shuffle() {
  if (this == null) {
    return null;
  }
  if (this!.isEmpty) {
    return this;
  }
  var stringArray = toArray();
  stringArray!.shuffle();
  return stringArray.join();
}