resolve static method

Map<String, String> resolve({
  1. required String rawProjectName,
  2. String? organization,
  3. String? description,
  4. String? author,
})

Resolves raw inputs into a complete token-to-value variable map.

Implementation

static Map<String, String> resolve({
  required String rawProjectName,
  String? organization,
  String? description,
  String? author,
}) {
  final trimmed = rawProjectName.trim();
  if (trimmed.isEmpty) {
    throw const ValidationException('Project name cannot be empty.');
  }

  final words = _extractWords(trimmed);
  if (words.isEmpty) {
    throw ValidationException('Invalid project name: "$rawProjectName"');
  }

  final snakeCase = words.map((w) => w.toLowerCase()).join('_');
  final pascalCase = words.map((w) => _capitalize(w)).join('');
  final camelCase = words.first.toLowerCase() +
      words.sublist(1).map((w) => _capitalize(w)).join('');

  final org = (organization != null && organization.trim().isNotEmpty)
      ? organization.trim()
      : 'com.example';

  final desc = (description != null && description.trim().isNotEmpty)
      ? description.trim()
      : 'A new Flutter project.';

  final auth = (author != null && author.trim().isNotEmpty)
      ? author.trim()
      : 'Developer';

  return {
    'project_name': trimmed,
    'project_name_snake_case': snakeCase,
    'project_name_pascal_case': pascalCase,
    'project_name_camel_case': camelCase,
    'organization': org,
    'description': desc,
    'author': auth,
  };
}