camelCase static method

String? camelCase(
  1. String value
)

camelCase string Example: your name => yourName

Implementation

static String? camelCase(String value) {
  if (isNullOrBlank(value)!) {
    return null;
  }

  final separatedWords = value
      .split(RegExp(r'[!@#<>?":`~;[\]\\|=+)(*&^%\-\s_]+'))
      .where((word) => word.isNotEmpty)
      .toList();

  if (separatedWords.isEmpty) {
    return null;
  }

  var newString = '';

  for (final word in separatedWords) {
    newString += word[0].toUpperCase() + word.substring(1).toLowerCase();
  }

  return newString[0].toLowerCase() + newString.substring(1);
}