DEV Community

Mohan's TechVerse
Mohan's TechVerse

Posted on

Flutter Command line installation easy Way

****# ========================================================================
# ALL-IN-ONE FLUTTER INSTALLATION SCRIPT FOR WINDOWS
# Installs: Flutter (stable), Git, Android Studio to C:\flutter
# ========================================================================

Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Flutter All-in-One Installation Script" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""

# ================================
# 1. Install Git
# ================================
Write-Host "[1/5] Installing Git..." -ForegroundColor Yellow
winget install --id Git.Git -e --source winget --accept-package-agreements --accept-source-agreements --silent
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
Write-Host "Git installed successfully!" -ForegroundColor Green
Write-Host ""

# ================================
# 2. Install Android Studio
# ================================
Write-Host "[2/5] Installing Android Studio..." -ForegroundColor Yellow
winget install -e --id Google.AndroidStudio --accept-package-agreements --accept-source-agreements --silent
Write-Host "Android Studio installed successfully!" -ForegroundColor Green
Write-Host ""

# ================================
# 3. Create Flutter directory
# ================================
Write-Host "[3/5] Creating C:\flutter directory..." -ForegroundColor Yellow
$flutterRoot = "C:\flutter"
if (Test-Path $flutterRoot) {
    Write-Host "Warning: C:\flutter already exists. Removing old installation..." -ForegroundColor Red
    Remove-Item -Path $flutterRoot -Recurse -Force
}
New-Item -ItemType Directory -Path $flutterRoot -Force | Out-Null
Write-Host "Directory created!" -ForegroundColor Green
Write-Host ""

# ================================
# 4. Clone Flutter SDK (Stable)
# ================================
Write-Host "[4/5] Downloading Flutter SDK (Stable branch)..." -ForegroundColor Yellow
Write-Host "This may take 5-10 minutes depending on your connection..." -ForegroundColor Cyan
Set-Location C:\
git clone https://github.com/flutter/flutter.git -b stable $flutterRoot --depth 1
Write-Host "Flutter SDK downloaded successfully!" -ForegroundColor Green
Write-Host ""

# ================================
# 5. Add Flutter to PATH
# ================================
Write-Host "[5/5] Adding Flutter to PATH..." -ForegroundColor Yellow
$flutterBin = "C:\flutter\bin"
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")

if ($currentPath -notlike "*$flutterBin*") {
    $newPath = if ($currentPath) { "$currentPath;$flutterBin" } else { $flutterBin }
    [Environment]::SetEnvironmentVariable("Path", $newPath, "User")
    Write-Host "Flutter added to PATH!" -ForegroundColor Green
} else {
    Write-Host "Flutter already in PATH!" -ForegroundColor Green
}
Write-Host ""

# ================================
# Installation Complete
# ================================
Write-Host "========================================" -ForegroundColor Green
Write-Host "     INSTALLATION COMPLETED!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
Write-Host ""
Write-Host "NEXT STEPS:" -ForegroundColor Cyan
Write-Host "1. CLOSE this PowerShell window" -ForegroundColor White
Write-Host "2. Open a NEW PowerShell/Command Prompt" -ForegroundColor White
Write-Host "3. Run these commands:" -ForegroundColor White
Write-Host "   flutter --version" -ForegroundColor Yellow
Write-Host "   flutter doctor" -ForegroundColor Yellow
Write-Host "   flutter doctor --android-licenses" -ForegroundColor Yellow
Write-Host ""
Write-Host "4. Open Android Studio and complete initial setup" -ForegroundColor White
Write-Host "5. Install Flutter & Dart plugins in Android Studio" -ForegroundColor White
Write-Host ""
Write-Host "Installation location: C:\flutter" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Green

Enter fullscreen mode Exit fullscreen mode

Top comments (0)