titlecase function

String titlecase(
  1. String s
)

Convert a string to Title Case (basic implementation).

Implementation

String titlecase(String s) => s
    .split(RegExp(r'\s+'))
    .where((w) => w.isNotEmpty)
    .map((w) => w[0].toUpperCase() + (w.length > 1 ? w.substring(1).toLowerCase() : ''))
    .join(' ');