scaffoldProject function

Future<void> scaffoldProject(
  1. Config config
)

Scaffolds a new Flutter project based on the provided config.

This function orchestrates the entire project creation process:

  1. Creates the base Flutter project.
  2. Adds necessary dependencies based on user choices.
  3. Generates and modifies project files.
  4. Formats the newly generated project.

Implementation

Future<void> scaffoldProject(Config config) async {
  logInfo("Creating project...");
  await _createProject(config);
  logInfo("Adding dependencies...");
  await _addDependencies(config);
  logInfo("Generating project files...");
  await _generateProjectFiles(config);

  logInfo("Formatting project...");
  final projectDir = Directory(config.projectName);

  final result = await Process.run(
    'dart',
    ['format', '.'],
    runInShell: true,
    workingDirectory: projectDir.path,
  );

  if (result.exitCode == 0) {
    logInfo("[ Formatted Project ]\n${result.stdout}");
  } else {
    logError("[ Formatting Project Failed ]\n${result.stderr}");
  }
  logSuccess("Project created successfully!");
}