Skip to content

Instantly share code, notes, and snippets.

@kabirnayeem99
Last active May 3, 2025 16:22
Show Gist options
  • Save kabirnayeem99/cf606467c08ef658b5cf90dddbc90491 to your computer and use it in GitHub Desktop.
Save kabirnayeem99/cf606467c08ef658b5cf90dddbc90491 to your computer and use it in GitHub Desktop.
Efficient Project Cleanup Script with Loading Indicators for Flutter and Dart Applications
#!/bin/bash
show_loading() {
local description="$1"
local process_id="$2"
local spinner_list='⡿⣟⣯⣷⣾⣽⣻⢿'
local spinner_index=0
echo -n "$description"
while ps -p "$process_id" >/dev/null; do
printf "\b\033[35m%s\033[0m" "${spinner_list:spinner_index++%${#spinner_list}:1}"
sleep 0.025
done
if [ $? -eq 0 ]; then
echo -e "\b\033[32m✓\033[0m"
else
echo -e "\b\033[31m𐄂\033[0m"
fi
}
run_command_with_loading() {
local command="$1"
local description="$2"
$command &
local pid=$!
show_loading "$description" "$pid"
}
cleanup_project() {
echo -e "Cleaning up project... \n"
run_command_with_loading "flutter pub add --dev import_sorter" "Adding import_sorter package"
run_command_with_loading "flutter pub add --dev import_path_converter" "Adding import_path_converter package"
run_command_with_loading "flutter pub get" "Getting dependencies"
run_command_with_loading "dart fix --apply" "Fixing code"
run_command_with_loading "dart format --fix ." "Following dart guidelines"
run_command_with_loading "flutter pub run import_path_converter:main" "Converting import paths from relative to absolute"
run_command_with_loading "flutter pub run import_sorter:main" "Organizing imports"
run_command_with_loading "flutter pub upgrade --major-versions" "Upgrading dependencies"
run_command_with_loading "flutter pub upgrade" "Upgrading dependencies (second pass)"
echo -e "\n\033[32m✓ All cleaning tasks finished. \033[0m"
}
cleanup_project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment