snakeCaseClass method

String snakeCaseClass({
  1. RegExp? regExp,
})

Implementation

String snakeCaseClass({RegExp? regExp}) {
  regExp ??= RegExp(r"(_)", caseSensitive: false);
  String text = "";
  for (var i = 0; i < length; i++) {
    var loopData = this[i];
    if (RegExp(r"[A-Z]").hashData(loopData) && i != 0) {
      text += "_${loopData}";
    } else {
      text += loopData;
    }
  }
  return text.toLowerCase();
}