removeSpaceAndAddNewLine method

String removeSpaceAndAddNewLine()

Implementation

String removeSpaceAndAddNewLine() {
  final wordList = split(' ');
  if (wordList.length <= 1) return this;
  if (wordList.length == 2) return wordList.join('\n');

  final lastWord = wordList.removeLast();
  return '${wordList.join(' ')}\n$lastWord';
}