toCamelCase property
String
get
toCamelCase
Converts string to camelCase (e.g. "hello_world" -> "helloWorld").
Implementation
String get toCamelCase {
if (isBlank) return '';
final words = trim().split(RegExp(r'[\s_\-]+'));
if (words.isEmpty) return '';
final first = words.first.toLowerCase();
final rest =
words
.skip(1)
.map(
(w) =>
w.isEmpty
? ''
: w[0].toUpperCase() + w.substring(1).toLowerCase(),
)
.join();
return '$first$rest';
}