I made this script to install Flutter:
Write-Host "Installing Flutter..." -ForegroundColor Cyan
$zipFile = "$env:TEMP\flutter.zip"
Write-Host "Downloading..."
(New-Object Net.WebClient).DownloadFile('https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_3.0.5-stable.zip', $zipFile)
Write-Host "Unzipping..."
Expand-Archive -Path "$zipFile" -DestinationPath "C:\src\flutter" -Verbose
[Environment]::SetEnvironmentVariable('Path', "$([Environment]::GetEnvironmentVariable('Path', 'Machine'));C:\src\flutter\flutter\bin", 'Machine')
flutter --version
it fails on the flutter --version
because I have to reload the PowerShell for the new PATH to have an effect. Is there a command to reload the PATH while running the script? I needed this to work on the current shell as well, but not setting a temporary path on the current shell, that is, I need to test if this set really worked