Created
June 2, 2025 12:20
-
-
Save luskan/fe6b51e8c66f96d098d3150be8233d7f to your computer and use it in GitHub Desktop.
Download specified by parameter flutter version, unpack it, put it in a new folder with version name, and symlink it to flutter folder.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <flutter_version>" | |
echo "Example: ./install_flutter.sh 3.32.1" | |
exit 1 | |
fi | |
FLUTTER_VERSION=$1 | |
FLUTTER_DIR="/var/flutter" | |
cd "$FLUTTER_DIR" || { echo "Cannot cd to $FLUTTER_DIR"; exit 1; } | |
# Remove previous symbolic link if exists | |
if [ -L flutter ]; then | |
rm flutter | |
fi | |
# Download the Flutter SDK | |
FLUTTER_ARCHIVE="flutter_linux_${FLUTTER_VERSION}-stable.tar.xz" | |
wget "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/${FLUTTER_ARCHIVE}" || { echo "Download failed"; exit 1; } | |
# Extract the Flutter SDK | |
tar -xf "${FLUTTER_ARCHIVE}" -C . || { echo "Extraction failed"; exit 1; } | |
# Rename extracted folder | |
mv flutter "flutter_${FLUTTER_VERSION}" || { echo "Rename failed"; exit 1; } | |
# Create symbolic link | |
ln -sf "flutter_${FLUTTER_VERSION}" flutter | |
# Clean up archive file | |
rm "${FLUTTER_ARCHIVE}" | |
echo "Flutter ${FLUTTER_VERSION} installed successfully." | |
# Optional: run flutter doctor | |
"${FLUTTER_DIR}/flutter/bin/flutter" doctor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment