Skip to content

Instantly share code, notes, and snippets.

@s0nerik
Last active March 28, 2020 02:31
Show Gist options
  • Save s0nerik/85dd7dc1c87d99f8219d309a8d4a7b07 to your computer and use it in GitHub Desktop.
Save s0nerik/85dd7dc1c87d99f8219d309a8d4a7b07 to your computer and use it in GitHub Desktop.
Flutter version changer

How it works

This script creates/maintains a symlink to the Flutter SDK of choice. It provides a way to quickly switch Flutter SDK version globally for the whole system.

How to use it

  1. Put flutter_version.sh into your home folder
  2. Run chmod +x flutter_version.sh
  3. Replace ~/Documents/SDKs on line 16 with a path to the folder where you want to store the Flutter SDK versions
  4. Download and put whichever versions of flutter you'd like to switch between into <SDKs path>/flutter_versions folder and name them conveniently. Something like 1.12 and 1.16_beta will work well.
  5. Add <SDKs path>/flutter/bin into PATH
  6. Run ./flutter_version.sh list to see the available versions
  7. Use ./flutter_version.sh <version_name> to switch between the Flutter SDK versions
#/bin/bash
main() {
if [[ "$1" == "list" ]]; then
ls flutter_versions
elif [ -d "flutter_versions/$1" ]; then
unlink flutter > /dev/null 2>&1
ln -s "flutter_versions/$1" flutter
else
echo "Version $1 doesn't exist"
echo "Available versions:"
ls flutter_versions
fi
}
( cd ~/Documents/SDKs ; main $* )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment