4 # homepage: https://flutter.dev
5 # tagline: UI Toolkit for mobile, web, and desktop
7 # Flutter is Google’s UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase.
10 # flutter create my_app
16 FLUTTER_VER=${WEBI_VERSION:-}
17 FLUTTER_VER="${FLUTTER_VER:-v}"
21 FLUTTER_OS="${WEBI_OS}" # linux or darwin
22 if [ "darwin" == "$FLUTTER_OS" ]; then
33 get_flutter_version() {
35 my_count=$(awk -F"${my_char}" '{print NF-1}' <<< "${FLUTTER_VER}")
36 # get the latest version if partial
37 if [ $my_count -ne 2 ]; then
38 if [ "$FLUTTER_VER" != "v" ]; then
39 FLUTTER_VER="$FLUTTER_VER\\."
42 if [ -n "$(type -p curl)" ]; then
44 elif [ -n "$(type -p wget)" ]; then
45 get_http="wget --quiet -O -"
47 echo "Found neither 'curl' nor 'wget'. Can't Continue."
51 FLUTTER_PATH=$($get_http "https://storage.googleapis.com/flutter_infra/releases/releases_${FLUTTER_OS}.json" | grep ${FLUTTER_OS} | grep ${FLUTTER_VER} | grep stable | head -n 1 | cut -d '"' -f 4) \
52 || echo 'error automatically determining current Flutter version'
53 FLUTTER_VER=$(echo $FLUTTER_PATH | sed 's/.*flutter_.*_v//' | sed 's/-stable.*//')
61 flutter_install_path=$HOME/.local/opt/flutter_${FLUTTER_VER}
62 mkdir -p "$flutter_install_path"
64 # TODO warn if existing flutter in path my take precedence
65 if [ -e "$flutter_install_path/bin/flutter" ]; then
66 # flutter of some version is already installed
67 if [ "${FLUTTER_VER}" == "$($flutter_install_path/bin/flutter --version | head -n 1 | cut -d ' ' -f2 2>/dev/null)" ]; then
68 echo flutter_${FLUTTER_VER} already installed at $flutter_install_path
73 # flutter_linux_v0.9.0-dev # flutter_linux_v0.9.0-dev.tar.xz
74 FLUTTER_PRE="flutter_${FLUTTER_OS}_${FLUTTER_VER}-stable"
75 FLUTTER_REMOTE="https://storage.googleapis.com/flutter_infra/releases/${FLUTTER_PATH}"
76 FLUTTER_LOCAL="$my_tmp/${FLUTTER_PRE}.${EXT}"
77 FLUTTER_UNTAR="$my_tmp/${FLUTTER_PRE}"
79 if [ -n "$(command -v curl 2>/dev/null | grep curl)" ]; then
80 curl -fSL ${FLUTTER_REMOTE} -o ${FLUTTER_LOCAL} || echo 'error downloading flutter'
81 elif [ -n "$(command -v wget 2>/dev/null | grep wget)" ]; then
82 wget ${FLUTTER_REMOTE} -O ${FLUTTER_LOCAL} || echo 'error downloading flutter'
84 echo "'wget' and 'curl' are missing. Please run the following command and try again"
85 echo " sudo apt-get install --yes curl wget"
89 mkdir -p ${FLUTTER_UNTAR}/
90 # --strip-components isn't portable, switch to portable version by performing move step after untar
91 if [ "zip" == "$EXT" ]; then
92 pushd ${FLUTTER_UNTAR}/
93 unzip ${FLUTTER_LOCAL}
96 tar xf ${FLUTTER_LOCAL} -C ${FLUTTER_UNTAR}/ #--strip-components=1
98 if [ -n "$(command -v rsync 2>/dev/null | grep rsync)" ]; then
99 echo rsync -Krl "${FLUTTER_UNTAR}"/flutter/ "$flutter_install_path/"
100 rsync -Krl "${FLUTTER_UNTAR}/flutter/" "$flutter_install_path/"
102 echo cp -Hr "${FLUTTER_UNTAR}/"flutter/* "${FLUTTER_UNTAR}/"flutter/.* "$flutter_install_path/"
103 cp -Hr "${FLUTTER_UNTAR}/"flutter/* "${FLUTTER_UNTAR}/"flutter/.* "$flutter_install_path/"
105 rm -rf "${FLUTTER_UNTAR}"
111 # TODO add more than one at a time
112 pathman add $flutter_install_path/bin