createBackup static method

Future<bool> createBackup()

Create a backup of the current pubspec.yaml file Returns true if backup was created successfully

Implementation

static Future<bool> createBackup() async {
  try {
    final pubspecFile = File(FileConfig.pubspecFile);

    // Check if pubspec.yaml exists
    if (!pubspecFile.existsSync()) {
      throw Exception('${FileConfig.pubspecFile} not found');
    }

    // Create backup by copying the file
    await pubspecFile.copy(FileConfig.backupFile);

    return true;
  } catch (e) {
    return false;
  }
}