Fix build script for flutter

This commit is contained in:
Khushboo Verma 2025-08-08 17:18:11 +05:30
parent 774da7ad6c
commit fcc2384a5e
2 changed files with 19 additions and 13 deletions

View File

@ -24,7 +24,7 @@ Alternatively, open the repository URL in `Android Studio` to clone it directly.
## 🛠️ Development Guide ## 🛠️ Development Guide
1. **Configure Appwrite** 1. **Configure Appwrite**
Navigate to `lib/data/repository/appwrite_repository.dart` and update the values to match your Copy `.env.example` to `.env` and update the values to match your
Appwrite project credentials. Appwrite project credentials.
2. **Customize as Needed** 2. **Customize as Needed**
@ -32,8 +32,7 @@ Alternatively, open the repository URL in `Android Studio` to clone it directly.
integrations as per your needs. integrations as per your needs.
3. **Run the App** 3. **Run the App**
Select a target device (emulator or a connected physical device) in `Android Studio`, and Run by executing `./build.sh {device-name}` like `./build.sh chrome`
click **Run** to start the app.
--- ---

View File

@ -10,20 +10,27 @@ if [ ! -f .env ]; then
fi fi
# Read .env file and convert it to --dart-define arguments # Read .env file and convert it to --dart-define arguments
ARGS="" ARGS=()
while IFS='=' read -r key value || [ -n "$key" ]; do while IFS='=' read -r key value || [ -n "$key" ]; do
# Ignore empty lines and comments # Ignore empty lines and comments
if [[ -n "$key" && ! "$key" =~ ^# ]]; then if [[ -n "$key" && ! "$key" =~ ^# ]]; then
ARGS+=" --dart-define=${key}=\"${value}\"" ARGS+=("--dart-define=${key}=${value}")
fi fi
done < .env done < .env
# Build Flutter web # Check if device parameter is provided
eval flutter build web "$ARGS" if [ -z "$1" ]; then
echo "Usage: ./build.sh <device_id_or_name>"
# If --preview flag is provided, run a local preview server echo "Example: ./build.sh chrome"
if [ "$1" == "--preview" ]; then echo "Example: ./build.sh 'iPhone 15'"
echo "Starting preview server at http://localhost:3000..." echo ""
cd build/web || exit 1 echo "Available devices:"
python3 -m http.server 3000 flutter devices
exit 1
fi fi
DEVICE_NAME="$1"
# Run Flutter app on specified device
echo "Running Flutter app on device: $DEVICE_NAME"
flutter run -d "$DEVICE_NAME" "${ARGS[@]}"