Add a helper script to choose the device and run flutter on it

It makes the entire process so much easier when you have multiple adb
devices.
This commit is contained in:
Vishesh Handa
2019-02-16 11:33:18 +01:00
parent 892a575227
commit 7dc6433538

17
scripts/flutter_run.sh Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -eu
DEVICES=$(adb devices -l | tail -n +2)
NUM_DEVICES=$(echo "$DEVICES" | wc -l)
if [ "$NUM_DEVICES" = 1 ]; then
DEVICE_ID="$DEVICES"
else
DEVICE_ID=$(echo "$DEVICES" | fzf)
fi
DEVICE_ID=$(echo "$DEVICE_ID" | awk '{ print $1 }')
echo "Running on $DEVICE_ID"
flutter run -d "$DEVICE_ID" --pid-file /tmp/flutter.pid --observatory-port 8888 "$@"