-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflutter_setup.ps1
More file actions
125 lines (101 loc) · 4.34 KB
/
flutter_setup.ps1
File metadata and controls
125 lines (101 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Flutter Development Setup Script for Flexlink
# This script sets up Flutter development environment on Windows
param(
[switch]$Force = $false,
[switch]$SkipAndroid = $false,
[switch]$Verbose = $false
)
$ErrorActionPreference = "Stop"
# Colors
function Write-Success { param([string]$Message) Write-Host "✅ $Message" -ForegroundColor Green }
function Write-Error { param([string]$Message) Write-Host "❌ $Message" -ForegroundColor Red }
function Write-Info { param([string]$Message) Write-Host "ℹ️ $Message" -ForegroundColor Blue }
function Write-Warning { param([string]$Message) Write-Host "⚠️ $Message" -ForegroundColor Yellow }
Write-Host "`n🚀 Flutter Setup for Flexlink Development" -ForegroundColor Cyan
Write-Host "========================================`n" -ForegroundColor Cyan
# Check if Flutter is already installed
$flutterPath = "$env:USERPROFILE\flutter"
if ((Test-Path "$flutterPath\bin\flutter.exe") -and !$Force) {
Write-Success "Flutter is already installed at $flutterPath"
# Add to PATH if not already there
$currentPath = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($currentPath -notlike "*$flutterPath\bin*") {
Write-Info "Adding Flutter to PATH..."
[Environment]::SetEnvironmentVariable("PATH", "$currentPath;$flutterPath\bin", "User")
$env:PATH += ";$flutterPath\bin"
Write-Success "Flutter added to PATH"
}
# Run Flutter Doctor
Write-Info "Running Flutter Doctor..."
flutter doctor -v
exit 0
}
# Download and install Flutter
Write-Info "Downloading Flutter SDK..."
$downloadUrl = "https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_3.16.0-stable.zip"
$zipPath = "$env:TEMP\flutter_windows.zip"
try {
# Download Flutter
Write-Info "Downloading from: $downloadUrl"
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath -UseBasicParsing
Write-Success "Flutter SDK downloaded successfully"
# Extract Flutter
Write-Info "Extracting Flutter SDK to $env:USERPROFILE..."
if (Test-Path $flutterPath) {
if ($Force) {
Remove-Item $flutterPath -Recurse -Force
} else {
Write-Warning "Flutter directory already exists. Use -Force to overwrite."
exit 1
}
}
Expand-Archive -Path $zipPath -DestinationPath $env:USERPROFILE -Force
Write-Success "Flutter SDK extracted"
# Add to PATH
Write-Info "Adding Flutter to PATH..."
$currentPath = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($currentPath -notlike "*$flutterPath\bin*") {
[Environment]::SetEnvironmentVariable("PATH", "$currentPath;$flutterPath\bin", "User")
$env:PATH += ";$flutterPath\bin"
Write-Success "Flutter added to PATH"
}
# Clean up
Remove-Item $zipPath -Force
# Configure Flutter
Write-Info "Configuring Flutter..."
# Accept Android licenses (if Android development needed)
if (!$SkipAndroid) {
Write-Info "Configuring Android development..."
try {
flutter doctor --android-licenses 2>$null
Write-Success "Android licenses accepted"
} catch {
Write-Warning "Could not accept Android licenses. You may need to install Android Studio."
}
}
# Enable web and desktop
Write-Info "Enabling Flutter web and desktop support..."
flutter config --enable-web
flutter config --enable-windows-desktop
Write-Success "Flutter configuration completed"
# Run Flutter Doctor
Write-Info "Running Flutter Doctor to check installation..."
flutter doctor -v
Write-Success "Flutter setup completed successfully!"
Write-Info "`nNext steps:"
Write-Info "1. Restart your terminal/PowerShell"
Write-Info "2. Run 'flutter doctor' to verify installation"
Write-Info "3. Install Android Studio for mobile development (optional)"
Write-Info "4. Install VS Code Flutter extension (recommended)"
} catch {
Write-Error "Flutter installation failed: $_"
# Cleanup on failure
if (Test-Path $zipPath) {
Remove-Item $zipPath -Force
}
if (Test-Path $flutterPath -and $Force) {
Remove-Item $flutterPath -Recurse -Force
}
exit 1
}
Write-Host "`n🎉 Flutter is ready for Flexlink development!" -ForegroundColor Green