createFeatureFolders method

void createFeatureFolders(
  1. String featureName,
  2. String projectDir
)

Implementation

void createFeatureFolders(String featureName, String projectDir) {
  final basePath = path.join(projectDir, 'lib/features/$featureName');

  // List of directories to be created based on the shown structure
  final directories = [
    '$basePath/data',
    '$basePath/data/datasources',
    '$basePath/data/models',
    '$basePath/data/repositories',
    '$basePath/domain',
    '$basePath/domain/entities',
    '$basePath/domain/repositories',
    '$basePath/domain/usecases',
    '$basePath/presentation',
    '$basePath/presentation/bloc',
    '$basePath/presentation/pages',
    '$basePath/presentation/widgets',
  ];

  for (final dir in directories) {
    final directory = Directory(dir);
    if (!directory.existsSync()) {
      directory.createSync(recursive: true);
      print('Created directory: $dir');
    } else {
      printWarning('Directory already exists: $dir');
    }
  }

  // Create the page file inside the pages folder
  createPageFile(featureName, basePath);

  // Create bloc files (bloc, event, state)
  createBlocFiles(featureName, basePath);

  // Create repository files
  createRepositoryFiles(featureName, basePath);

  // Create entity file
  createEntityFile(featureName, basePath);

  // Create model file
  createModelFile(featureName, basePath);

  // Create datasource file
  createDatasourceFile(featureName, basePath);

  // Create usecases
  createUsecaseFiles(featureName, basePath);
}