label property
String
get
label
The value's name split into words, like Dark mode for darkMode.
Works with camelCase and snake_case names.
Implementation
String get label {
final String words = name
.replaceAllMapped(
RegExp('(?<=[a-z0-9])([A-Z])'),
(match) => ' ${match[1]}',
)
.replaceAll('_', ' ')
.trim()
.toLowerCase();
if (words.isEmpty) return words;
return '${words[0].toUpperCase()}${words.substring(1)}';
}