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
29 get_flutter_version() {
31 my_count=$(awk -F"${my_char}" '{print NF-1}' <<< "${FLUTTER_VER}")
32 # get the latest version if partial
33 if [ $my_count -ne 2 ]; then
34 if [ "$FLUTTER_VER" != "v" ]; then
35 FLUTTER_VER="$FLUTTER_VER\\."
38 if [ -n "$(type -p curl)" ]; then
40 elif [ -n "$(type -p wget)" ]; then
41 get_http="wget --quiet -O -"
43 echo "Found neither 'curl' nor 'wget'. Can't Continue."
47 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) \
48 || echo 'error automatically determining current Flutter version'
49 FLUTTER_VER=$(echo $FLUTTER_PATH | sed 's/.*flutter_.*_v//' | sed 's/-stable.*//')
57 flutter_install_path=$HOME/.local/opt/flutter_${FLUTTER_VER}
58 mkdir -p "$flutter_install_path"
60 # TODO warn if existing flutter in path my take precedence
61 if [ -e "$flutter_install_path/bin/flutter" ]; then
62 # flutter of some version is already installed
63 if [ "${FLUTTER_VER}" == "$($flutter_install_path/bin/flutter --version | head -n 1 | cut -d ' ' -f2 2>/dev/null)" ]; then
64 echo flutter_${FLUTTER_VER} already installed at $flutter_install_path
69 # flutter_linux_v0.9.0-dev # flutter_linux_v0.9.0-dev.tar.xz
70 FLUTTER_PRE="flutter_${FLUTTER_OS}_${FLUTTER_VER}-stable"
71 FLUTTER_REMOTE="https://storage.googleapis.com/flutter_infra/releases/${FLUTTER_PATH}"
72 FLUTTER_LOCAL="$my_tmp/${FLUTTER_PRE}.${EXT}"
73 FLUTTER_UNTAR="$my_tmp/${FLUTTER_PRE}"
75 if [ -n "$(command -v curl 2>/dev/null | grep curl)" ]; then
76 curl -fSL ${FLUTTER_REMOTE} -o ${FLUTTER_LOCAL} || echo 'error downloading flutter'
77 elif [ -n "$(command -v wget 2>/dev/null | grep wget)" ]; then
78 wget ${FLUTTER_REMOTE} -O ${FLUTTER_LOCAL} || echo 'error downloading flutter'
80 echo "'wget' and 'curl' are missing. Please run the following command and try again"
81 echo " sudo apt-get install --yes curl wget"
85 mkdir -p ${FLUTTER_UNTAR}/
86 # --strip-components isn't portable, switch to portable version by performing move step after untar
87 if [ "zip" == "$EXT" ]; then
88 pushd ${FLUTTER_UNTAR}/
89 unzip ${FLUTTER_LOCAL}
92 tar xf ${FLUTTER_LOCAL} -C ${FLUTTER_UNTAR}/ #--strip-components=1
94 if [ -n "$(command -v rsync 2>/dev/null | grep rsync)" ]; then
95 echo rsync -Krl "${FLUTTER_UNTAR}"/flutter/ "$flutter_install_path/"
96 rsync -Krl "${FLUTTER_UNTAR}/flutter/" "$flutter_install_path/"
98 echo cp -Hr "${FLUTTER_UNTAR}/"flutter/* "${FLUTTER_UNTAR}/"flutter/.* "$flutter_install_path/"
99 cp -Hr "${FLUTTER_UNTAR}/"flutter/* "${FLUTTER_UNTAR}/"flutter/.* "$flutter_install_path/"
101 rm -rf "${FLUTTER_UNTAR}"
107 # TODO add more than one at a time
108 pathman add $flutter_install_path/bin