fromCamelCase method

  1. @override
String fromCamelCase(
  1. String propertyName
)
override

Converts a property name from camelCase to this convention.

@param propertyName The property name in camelCase format. @returns The property name converted to this convention's format.

Implementation

@override
String fromCamelCase(String propertyName) {
  if (propertyName.isEmpty) return propertyName;

  final codeUnits = propertyName.codeUnits;
  final buffer = StringBuffer();
  final separatorCode = _separator.codeUnitAt(0);

  for (var i = 0; i < codeUnits.length; i++) {
    final codeUnit = codeUnits[i];
    // Check if uppercase (A-Z: 65-90)
    if (codeUnit >= 65 && codeUnit <= 90) {
      if (i > 0) {
        buffer.writeCharCode(separatorCode);
      }
      // Convert to lowercase
      buffer.writeCharCode(codeUnit + 32);
    } else {
      buffer.writeCharCode(codeUnit);
    }
  }

  return buffer.toString();
}