uncamelize static method

String uncamelize(
  1. String name
)

Uncamelizes the give string.

  • For example, backgroundColor' => background-color`.

Implementation

static String uncamelize(String name) {
  StringBuffer? sb;
  int k = 0;
  for (int i = 0, len = name.length; i < len; ++i) {
    final cc = name.codeUnitAt(i);
    if (cc >= $A && cc <= $Z) {
      if (sb == null) sb = StringBuffer();
      sb..write(name.substring(k, i))..write('-')..write(name[i].toLowerCase());
      k = i + 1;
    }
  }
  return sb != null ? (sb..write(name.substring(k))).toString(): name;
}