$ErrorActionPreference = "Stop" Write-Host "" Write-Host "=== YouTube Personal - Fix File Picker Android 18.10.1 ===" -ForegroundColor Cyan Write-Host "Projet : $PWD" Write-Host "" if (-not (Test-Path ".\pubspec.yaml")) { throw "pubspec.yaml introuvable. Lance ce script depuis la racine du projet Flutter." } if (-not (Test-Path ".\lib\services\memory_backup_service.dart")) { throw "lib/services/memory_backup_service.dart introuvable. Extrais d'abord tout le ZIP dans la racine du projet." } # Ferme uniquement l'executable Windows de l'application s'il tourne encore. Get-Process -Name "youtube_personal" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue $pubspecPath = ".\pubspec.yaml" $backupPath = ".\pubspec.yaml.before_file_picker_12" if (-not (Test-Path $backupPath)) { Copy-Item $pubspecPath $backupPath Write-Host "[OK] Sauvegarde pubspec : $backupPath" -ForegroundColor Green } Write-Host "[1/4] Passage a file_picker 12.0.0..." -ForegroundColor Yellow $content = Get-Content $pubspecPath -Raw if ($content -match '(?m)^\s*file_picker\s*:\s*.*$') { $content = [regex]::Replace( $content, '(?m)^(\s*)file_picker\s*:\s*.*$', '${1}file_picker: 12.0.0', 1 ) } else { $dependencyAnchor = '(?m)^dependencies\s*:\s*$' if ($content -notmatch $dependencyAnchor) { throw "Section dependencies introuvable dans pubspec.yaml." } $content = [regex]::Replace( $content, $dependencyAnchor, "dependencies:`r`n file_picker: 12.0.0", 1 ) } Set-Content -Path $pubspecPath -Value $content -Encoding UTF8 Write-Host "[OK] file_picker verrouille sur 12.0.0." -ForegroundColor Green Write-Host "[2/4] Suppression du registrant Android genere precedent..." -ForegroundColor Yellow $registrant = ".\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java" if (Test-Path $registrant) { Remove-Item $registrant -Force Write-Host "[OK] GeneratedPluginRegistrant.java supprime. Flutter va le regenerer." -ForegroundColor Green } else { Write-Host "[INFO] Aucun registrant precedent a supprimer." -ForegroundColor DarkGray } if (Test-Path ".\.flutter-plugins-dependencies") { Remove-Item ".\.flutter-plugins-dependencies" -Force -ErrorAction SilentlyContinue } Write-Host "[3/4] Resolution des dependances..." -ForegroundColor Yellow flutter pub get if ($LASTEXITCODE -ne 0) { throw "flutter pub get a echoue." } Write-Host "[4/4] Formatage et verification rapide..." -ForegroundColor Yellow dart format ".\lib\services\memory_backup_service.dart" if ($LASTEXITCODE -ne 0) { throw "dart format a echoue." } Write-Host "" Write-Host "[OK] Correctif 18.10.1 applique." -ForegroundColor Green Write-Host "" Write-Host "Teste maintenant Android avec :" -ForegroundColor Cyan Write-Host "flutter run -d f10778d8" Write-Host "" Write-Host "Puis APK release avec :" -ForegroundColor Cyan Write-Host "flutter build apk --release" Write-Host ""