Skip to content

Instantly share code, notes, and snippets.

@mahmoudalaa97
Last active February 5, 2025 15:28
Show Gist options
  • Save mahmoudalaa97/e44cfd64a653533d37cca3808b6f32f0 to your computer and use it in GitHub Desktop.
Save mahmoudalaa97/e44cfd64a653533d37cca3808b6f32f0 to your computer and use it in GitHub Desktop.

Flutter Team Utility Script

A Bash script to automate common Flutter development tasks.

✨ Features

  • Clear CocoaPods & Cache and Reinstall (iOS)
  • Generate Build Files (build_runner)
  • Update Localization (flutter_lokalise)
  • Flutter Clean & Pub Get
  • Reset Android Gradle

πŸš€ How to Use

  1. Download the script and place it in your Flutter project root.
  2. Make it executable: chmod +x flutter_team_tool.sh
  3. **Run the Script **: ./flutter_team_tool.sh

πŸ“œ Script: flutter_team_tool.sh

πŸ“Œ Author

Created by Mahmoud Alaa πŸš€

#!/bin/bash
# ===========================================
# πŸ› οΈ Flutter Team Utility Script
# ✍️ Created by Mahmoud Alaa
# πŸš€ Automates common Flutter development tasks
# ===========================================
# 🎨 Define colors for better output visibility
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
# πŸ“œ Display the menu
echo -e "${YELLOW}πŸ”§ Flutter Team Utility Script - Created by Mahmoud Alaa${NC}"
echo "1️⃣ 🧹 Clear Pods & Cache and Reinstall (iOS)"
echo "2️⃣ πŸ“‚ Generate Build Files (build_runner)"
echo "3️⃣ 🌍 Update Localization (flutter_lokalise)"
echo "4️⃣ πŸ› οΈ Flutter Clean & Pub Get"
echo "5️⃣ πŸ”§ Reset Android Gradle"
echo "6️⃣ πŸ§ͺ Run Flutter Tests with Coverage"
echo "7️⃣ ❌ Exit"
read -p "πŸ“Œ Enter your choice: " choice
case $choice in
1)
echo -e "${YELLOW}🧹 Cleaning iOS Pods & Cache...${NC}"
flutter clean && flutter pub get
rm -rf ios/Pods ios/Flutter/Flutter.framework ios/Flutter/Flutter.podspec ios/Podfile.lock
cd ios || { echo -e "${RED}❌ Failed to enter ios directory!${NC}"; exit 1; }
pod deintegrate && pod install
cd ..
echo -e "${GREEN}βœ… iOS Cleanup Complete!${NC}"
;;
2)
echo -e "${YELLOW}πŸ“‚ Running Build Runner...${NC}"
flutter pub run build_runner build --delete-conflicting-outputs
echo -e "${GREEN}βœ… Build Files Generated Successfully!${NC}"
;;
3)
echo -e "${YELLOW}🌍 Updating Localization...${NC}"
flutter pub run flutter_lokalise download --output lib/i18n
echo -e "${GREEN}βœ… Localization Updated!${NC}"
;;
4)
echo -e "${YELLOW}πŸ› οΈ Running Flutter Clean & Pub Get...${NC}"
flutter clean && flutter pub get
echo -e "${GREEN}βœ… Flutter Project Cleaned & Dependencies Installed!${NC}"
;;
5)
echo -e "${YELLOW}πŸ”§ Resetting Android Gradle...${NC}"
rm -rf android/.gradle android/app/build
flutter clean && flutter pub get
echo -e "${GREEN}βœ… Android Gradle Reset Complete!${NC}"
;;
6)
echo -e "${YELLOW}πŸ§ͺ Running Flutter Tests with Coverage...${NC}"
flutter test --coverage
if [ -f "coverage/lcov.info" ]; then
echo -e "${YELLOW}πŸ“Š Generating HTML Report...${NC}"
genhtml coverage/lcov.info -o coverage/html
echo -e "${GREEN}βœ… Test Coverage Report Generated: coverage/html/index.html${NC}"
else
echo -e "${RED}❌ Coverage file not found. Make sure tests are running correctly.${NC}"
fi
;;
7)
echo -e "${YELLOW}❌ Exiting script.${NC}"
exit 0
;;
*)
echo -e "${RED}❌ Invalid choice. Please select a valid option.${NC}"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment