generateFolder function

void generateFolder(
  1. String name
)

The name parameter is the name of the folder to generate.

Implementation

void generateFolder(String name) {
  // Create a Directory object with the given name
  Directory root = Directory(name);

  // Check if the directory doesn't exist
  if (!root.existsSync()) {
    // Create the directory recursively
    root.createSync(recursive: true);

    // Generate a file inside the created directory
    generateFile(root.path);

    // Print a success message
    print('Folder $root created successfully');
  } else {
    // If the directory already exists, print a message
    print('Folder $root already exits');
  }

  // Create three additional directories: themes, core, and utils
  Directory themes = Directory('themes');
  Directory core = Directory('core');
  Directory utils = Directory('utils');

  // Create the themes directory and generate a file inside it
  themes
      .create(recursive: true)
      .then((value) => generateFile(value.path))
      .catchError((error) => print('Folder $error already exists'));

  // Create the core directory and generate a file inside it
  core
      .create(recursive: true)
      .then((value) => generateFile(value.path))
      .catchError((error) => print('Folder $error already exists'));

  // Create the utils directory and generate a file inside it
  utils
      .create(recursive: true)
      .then((value) => generateFile(value.path))
      .catchError((error) => print('Folder $error already exists'));

  // Call the subFolder function with the given name
  subFolder(name);
}