toScreamingSnakeCase function

String toScreamingSnakeCase(
  1. String string
)

Converts string to SCREAMING_SNAKE_CASE.

Implementation

String toScreamingSnakeCase(String string) {
  return string
      .replaceAllMapped(
          RegExp(r'(?<=[a-z])[A-Z]'), (Match m) => '_${m.group(0)}')
      .toUpperCase();
}