createRootPubspecSync method
Writes the workspace root pubspec.yaml with basic configuration.
Parameters:
dartVersion: Dart SDK version constraint (e.g.3.10.8).projectName: the main application folder name included in the workspace.
Implementation
void createRootPubspecSync({
required String dartVersion,
required String projectName,
}) {
log('📝 Creating root pubspec.yaml...');
final isDart311OrHigher = _isVersionAtLeast(dartVersion, 3, 11);
final workspaceSection =
isDart311OrHigher
? ' - $projectName\n - packages/*'
: ' - $projectName\n - packages/core';
final content = '''
name: _
version: 0.1.0
description: A Dart workspace example
publish_to: none
environment:
sdk: ^$dartVersion
workspace:
$workspaceSection
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
''';
final file = fs.file('pubspec.yaml');
file.writeAsStringSync(content);
log('✅ Root pubspec.yaml created');
}