createFlutterAppSync method

void createFlutterAppSync({
  1. required String projectName,
})

Scaffolds a new Flutter app by running flutter create <projectName>.

Parameters:

  • projectName: the folder/name of the Flutter application to create.

Throws:

  • Exception when the flutter create command fails.

Implementation

void createFlutterAppSync({required String projectName}) {
  try {
    log('📱 Creating Flutter app...');
    runner.runSync(
      'flutter',
      ['create', projectName],
      workingDirectory: fs.currentDirectory.path,
      runInShell: true,
    );
    log('✅ Flutter app created: $projectName');
  } catch (_) {
    throw Exception('Failed to create Flutter app');
  }
}