generate method
Implementation
Future<void> generate(ProjectConfig config) async {
final projectDir = Directory(config.projectPath);
if (projectDir.existsSync()) {
throw StateError('Directory already exists: ${config.projectPath}');
}
Logger.info('Creating project structure...');
projectDir.createSync(recursive: true);
await _runFlutterCreate(config);
Logger.info('Generating ${config.architecture.label} files...');
_writeArchitectureFiles(config);
Logger.info('Applying ${config.designPreset.id} design system...');
_writeDesignFiles(config);
Logger.info('Writing config files...');
_writeCommonFiles(config);
// `flutter pub get` and `git init` are independent of each other, so run
// them concurrently. The git commit (which needs `git init` to have run
// and all files to be written) happens afterward.
final hasGit = await ShellRunner.hasExecutable('git');
final spinner = Spinner('Installing dependencies & initializing git...');
spinner.start();
await Future.wait([
_runPubGet(config),
if (hasGit) _gitInit(config),
]);
spinner.stop();
Logger.info('Dependencies installed');
if (hasGit) {
await _gitCommit(config);
Logger.info('Initialized git repository');
}
Logger.success('Done!');
}