makeConfig static method

dynamic makeConfig(
  1. String configName,
  2. String value, {
  3. String folderPath = configFolder,
  4. bool forceCreate = false,
  5. String? creationPath,
})

Creates a new config file.

Implementation

static makeConfig(String configName, String value,
    {String folderPath = configFolder,
    bool forceCreate = false,
    String? creationPath}) async {
  String name = configName.replaceAll(RegExp(r'(_?config)'), "");

  // create missing directories in the project
  await _makeDirectory(folderPath);
  await createDirectoriesFromCreationPath(creationPath, folderPath);

  // create file path
  String filePath = createPathForDartFile(
      folderPath: folderPath, className: name, creationPath: creationPath);

  await _checkIfFileExists(filePath, shouldForceCreate: forceCreate);
  await _createNewFile(filePath, value, onSuccess: () {
    MetroConsole.writeInGreen('[Config] ${name.snakeCase} created 🎉');
  });
}