toScreamingCase method

  1. @useResult
String toScreamingCase([
  1. Pattern? separators
])

Screaming-cases this string.

wordSeparators is used to separate words if separators is not given.

'camelCase'.toScreamingCase(); // 'CAMEL_CASE'

'PascalCase'.toScreamingCase(); // 'PASCAL_CASE'

'SCREAMING_CASE'.toScreamingCase(); // 'SCREAMING_CASE'

'snake_case'.toScreamingCase(); // 'SNAKE_CASE'

'kebab-case'.toScreamingCase(); // 'KEBAB_CASE'

'Title Case'.toScreamingCase(); // 'TITLE_CASE'

'Sentence case'.toScreamingCase(); // 'SENTENCE_CASE'

Implementation

@useResult String toScreamingCase([Pattern? separators]) => split(separators ?? wordSeparators)
  .where((e) => e.isNotEmpty)
  .join('_')
  .toUpperCase();