Last active
February 16, 2024 08:01
-
-
Save sunderee/56970a1d0419457d8fe550819a44dbe8 to your computer and use it in GitHub Desktop.
Install stable version of Flutter on macOS (Apple Silicon chip)
This file contains 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
#!/usr/bin/env bash | |
set -euo pipefail | |
readonly FLUTTER_VERSION="3.19.0" | |
readonly URL="https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_arm64_${FLUTTER_VERSION}-stable.zip" | |
readonly DIRECTORY="${HOME}/flutter" | |
# Function to download and extract flutter | |
download_flutter() { | |
local temp_file | |
temp_file=$(mktemp) | |
curl -L -o "${temp_file}" "${URL}" | |
unzip -o "${temp_file}" -d "${HOME}" | |
rm "${temp_file}" | |
} | |
# Function to update path | |
update_path() { | |
local zshrc_file="${HOME}/.zshrc" | |
{ | |
echo "" | |
echo "# Flutter" | |
echo 'export PATH="${HOME}/flutter/bin:${PATH}"' | |
} >> "${zshrc_file}" | |
# Source .zshrc to update the path | |
source "${zshrc_file}" | |
} | |
# Main execution | |
main() { | |
mkdir -p "${DIRECTORY}" | |
download_flutter | |
update_path | |
# Print version to verify installation | |
flutter --version | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment