humanize method

String humanize()

Converts a string into a human-readable form by inserting spaces before uppercase letters and lowercasing the result.

'helloWorld'.humanize() // 'hello world'

Implementation

String humanize() {
  if (isEmpty) return '';
  return replaceAllMapped(RegExp(r'([A-Z])'), (m) => ' ${m[1]}')
      .trim()
      .toLowerCase();
}