toTrainCase method

String toTrainCase()

Converts a string to Train-Case.

'hello world'.toTrainCase() // 'Hello-World'

Implementation

String toTrainCase() {
  if (isEmpty) return '';
  return split(RegExp(r'[\s_\-]+')).map((w) => w.capitalize()).join('-');
}