titleized property

String titleized

convert to 'title' format: foo bar -> Foo Bar, or an empty string if it is blank. similar to camelCase, but each segment is separated by a space

Implementation

String get titleized => underscored.splitMapJoin('_',
    onMatch: (m) => ' ',
    onNonMatch: (n) => n.isEmpty
        ? ''
        : (n.length == 1)
            ? n.toUpperCase()
            : '${n[0].toUpperCase()}${n.substring(1).toLowerCase()}');