toCamelCase method

String toCamelCase(
  1. String text
)

Converts a string to camelCase naming convention.

text - The input text to convert.

Splits on underscores, hyphens, and spaces, then converts to camelCase. Example: 'user_profile' → 'userProfile'

Implementation

String toCamelCase(String text) {
  if (text.isEmpty) return text;
  final words = text.split(RegExp(r'[_\-\s]+'));
  return words.first.toLowerCase() +
         words.skip(1).map((word) => word.capitalize()).join();
}