String toSnakeCase(String text) { return text .replaceAll(RegExp(r'[A-Z]'), '_\$&') .replaceAll(RegExp(r'[-\s]+'), '_') .toLowerCase() .replaceAll(RegExp(r'^_'), ''); }