apiNameToVariableName function

String apiNameToVariableName(
  1. String name
)

Implementation

String apiNameToVariableName(String name) {
  if (name.startsWith(RegExp(r'\d+'))) {
    name = name.replaceFirst(RegExp(r'\d+'), '').trim();
  }
  name =
      name.replaceAll(RegExp(r'\s+'), '_').replaceAll(RegExp(r'\W'), '').trim();
  final tokens = name.split(RegExp(r'_+'));
  final sanitizedName = [
    SDKConstants.apiVariablePrefix,
    ...tokens.map((e) => e.capitalized)
  ].join('');
  return sanitizedName;
}