underscore method

String underscore()

Converts a camelized string to all lower case separated by underscores.

'helloWorld'.underscore() // '_hello_world'

Implementation

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