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.
12 FLUTTER_VER=${WEBI_VERSION:-}
13 FLUTTER_VER="${FLUTTER_VER:-v}"
17 FLUTTER_OS="${WEBI_OS}" # linux or darwin
18 if [ "darwin" == "$FLUTTER_OS" ]; then
30 get_flutter_version() {
32 my_count=$(awk -F"${my_char}" '{print NF-1}' <<< "${FLUTTER_VER}")
33 # get the latest version if partial
34 if [ $my_count -ne 2 ]; then
35 if [ "$FLUTTER_VER" != "v" ]; then
36 FLUTTER_VER="$FLUTTER_VER\\."
39 if [ -n "$(type -p curl)" ]; then
41 elif [ -n "$(type -p wget)" ]; then
42 get_http="wget --quiet -O -"
44 echo "Found neither 'curl' nor 'wget'. Can't Continue."
48 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) \
49 || echo 'error automatically determining current Flutter version'
50 FLUTTER_VER=$(echo $FLUTTER_PATH | sed 's/.*flutter_.*_v//' | sed 's/-stable.*//')
58 flutter_install_path=$HOME/.local/opt/flutter_${FLUTTER_VER}
59 mkdir -p "$flutter_install_path"
61 # TODO warn if existing flutter in path my take precedence
62 if [ -e "$flutter_install_path/bin/flutter" ]; then
63 # flutter of some version is already installed
64 echo "${FLUTTER_VER}" == "$($flutter_install_path/bin/flutter --version)"
65 if [ "${FLUTTER_VER}" == "$($flutter_install_path/bin/flutter --version | cut -d ' ' -f 3 2>/dev/null)" ]; then
66 echo ${FLUTTER_VER} already installed at $flutter_install_path
71 # flutter_linux_v0.9.0-dev # flutter_linux_v0.9.0-dev.tar.xz
72 FLUTTER_PRE="flutter_${FLUTTER_OS}_${FLUTTER_VER}-stable"
73 FLUTTER_REMOTE="https://storage.googleapis.com/flutter_infra/releases/${FLUTTER_PATH}"
74 FLUTTER_LOCAL="$my_tmp/${FLUTTER_PRE}.${EXT}"
75 FLUTTER_UNTAR="$my_tmp/${FLUTTER_PRE}"
77 if [ -n "$(command -v curl 2>/dev/null | grep curl)" ]; then
78 curl -fSL ${FLUTTER_REMOTE} -o ${FLUTTER_LOCAL} || echo 'error downloading flutter'
79 elif [ -n "$(command -v wget 2>/dev/null | grep wget)" ]; then
80 wget ${FLUTTER_REMOTE} -O ${FLUTTER_LOCAL} || echo 'error downloading flutter'
82 echo "'wget' and 'curl' are missing. Please run the following command and try again"
83 echo " sudo apt-get install --yes curl wget"
87 mkdir -p ${FLUTTER_UNTAR}/
88 # --strip-components isn't portable, switch to portable version by performing move step after untar
89 if [ "zip" == "$EXT" ]; then
90 pushd ${FLUTTER_UNTAR}/
91 unzip ${FLUTTER_LOCAL}
94 tar xf ${FLUTTER_LOCAL} -C ${FLUTTER_UNTAR}/ #--strip-components=1
96 if [ -n "$(command -v rsync 2>/dev/null | grep rsync)" ]; then
97 echo $sudo_cmd rsync -Krl "${FLUTTER_UNTAR}"/flutter/ "$flutter_install_path/"
98 rsync -Krl "${FLUTTER_UNTAR}/" "$flutter_install_path/" 2>/dev/null || $sudo_cmd rsync -Krl "${FLUTTER_UNTAR}/" "$flutter_install_path/"
100 echo $sudo_cmd cp -Hr "${FLUTTER_UNTAR}/"flutter/* "${FLUTTER_UNTAR}/"flutter/.* "$flutter_install_path/"
101 cp -Hr "${FLUTTER_UNTAR}"/* "$flutter_install_path/" 2>/dev/null || $sudo_cmd cp -Hr "${FLUTTER_UNTAR}"/* "$flutter_install_path/"
103 rm -rf "${FLUTTER_UNTAR}"
109 # TODO add more than one at a time
110 pathman add $flutter_install_path/bin