-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfvm_setup.sh
More file actions
executable file
·69 lines (58 loc) · 1.6 KB
/
fvm_setup.sh
File metadata and controls
executable file
·69 lines (58 loc) · 1.6 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
#!/bin/bash
# Check if we're in a Flutter project
if [ ! -f "pubspec.yaml" ]; then
echo "Error: pubspec.yaml not found. Are you in a Flutter project directory?"
exit 1
fi
# Check if FVM is installed
if ! command -v fvm &> /dev/null; then
echo "Error: FVM is not installed. Please install it first using:"
echo "brew tap leoafarias/fvm"
echo "brew install fvm"
exit 1
fi
# Initialize FVM in the project
echo "Initializing FVM in the project..."
fvm config
# Create .fvm directory if it doesn't exist
mkdir -p .fvm
# Add .fvm/flutter_sdk to .gitignore
if [ -f .gitignore ]; then
if ! grep -q "^.fvm/flutter_sdk" .gitignore; then
echo "" >> .gitignore
echo "# FVM" >> .gitignore
echo ".fvm/flutter_sdk" >> .gitignore
fi
else
echo ".fvm/flutter_sdk" > .gitignore
fi
# Install Flutter version
read -p "Enter Flutter version to use (e.g., stable, beta, 3.19.0): " version
fvm install $version
# Set the version for the project
fvm use $version
# Create VS Code settings if needed
mkdir -p .vscode
cat > .vscode/settings.json << EOF
{
"dart.flutterSdkPath": ".fvm/flutter_sdk",
"search.exclude": {
"**/.fvm": true
},
"files.watcherExclude": {
"**/.fvm": true
}
}
EOF
echo "
FVM setup complete! Your project is now configured to use Flutter $version
Next steps:
1. Run 'fvm flutter pub get' to install dependencies
2. Use 'fvm flutter' instead of 'flutter' for all commands
3. If using CI/CD, update your scripts to use FVM
Common commands:
- Build: fvm flutter build
- Run: fvm flutter run
- Test: fvm flutter test
- Clean: fvm flutter clean
"