label property

String get label

Returns the enum name as a human-readable title case string.

Status.activeUser.label // 'Active User'

Implementation

String get label {
  // Split camelCase name into words
  final words = name.replaceAllMapped(
    RegExp(r'([A-Z])'),
    (m) => ' ${m[1]}',
  );
  return words.trim().split(' ').map((w) {
    if (w.isEmpty) return '';
    return '${w[0].toUpperCase()}${w.substring(1).toLowerCase()}';
  }).join(' ');
}