formatProjectName method

String formatProjectName(
  1. String name
)

Formats project name to be Dart-compliant

Implementation

String formatProjectName(String name) {
  // Replace hyphens with underscores
  var formatted = name.replaceAll('-', '_');

  // Remove any invalid characters
  formatted = formatted.replaceAll(RegExp(r'[^a-z0-9_]'), '');

  // Ensure starts with a letter
  if (formatted.isEmpty || !RegExp(r'[a-z]').hasMatch(formatted[0])) {
    formatted = 'app_$formatted';
  }

  return formatted;
}