Skip to content

Instantly share code, notes, and snippets.

@sunderee
Last active February 16, 2024 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunderee/56970a1d0419457d8fe550819a44dbe8 to your computer and use it in GitHub Desktop.
Save sunderee/56970a1d0419457d8fe550819a44dbe8 to your computer and use it in GitHub Desktop.
Install stable version of Flutter on macOS (Apple Silicon chip)
#!/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