#!/bin/bash

# Run Flutter app with backend API connection
# This script runs Flutter with the backend API URL configured

set -e

# Navigate to project root
cd "$(dirname "$0")/.."

# Get API URL from environment or use default
API_BASE_URL="${API_BASE_URL:-http://localhost:8000}"

# Determine device (default to chrome for web)
DEVICE="${1:-chrome}"

echo "🚀 Running Flutter app with backend API..."
echo "   API URL: $API_BASE_URL"
echo "   Device: $DEVICE"
echo ""

# Run Flutter with environment variables
flutter run -d "$DEVICE" \
  --dart-define=API_BASE_URL="$API_BASE_URL"

