A multi-page Flutter weather dashboard application with offline support, caching, and index-based coordinate calculation. This app fetches real-time weather data from the Open-Meteo API and displays it in a beautiful, modern UI.
- Multi-Page Navigation: Smooth navigation between Get Started, Login, and Weather Dashboard pages
- Index-Based Coordinates: Automatically calculates latitude and longitude from student index number
- Real-Time Weather Data: Fetches current weather from Open-Meteo API
- Offline Support: Displays cached data when internet is unavailable
- Modern UI Design: Blue gradient theme with card-based layouts
- Error Handling: Graceful error messages and retry mechanisms
- Data Caching: Uses SharedPreferences for local data persistence
- Connectivity Detection: Automatically detects network status
Get Started Page โ Login Page โ Weather Dashboard Page
โ โ โ
Welcome UI Index Input Weather Display
Calculate Coords + Offline Cache
lib/
โโโ main.dart # App entry point
โโโ models/
โ โโโ weather_model.dart # Weather data model
โโโ services/
โ โโโ cache_service.dart # Local storage service
โ โโโ weather_service.dart # API service
โโโ widgets/
โ โโโ loading_indicator.dart # Loading animations
โ โโโ weather_card.dart # Weather display card
โโโ pages/
โโโ get_started_page.dart # Welcome screen
โโโ login_page.dart # Index input screen
โโโ weather_page.dart # Weather dashboard
- Flutter SDK (3.0 or higher)
- Dart SDK (3.0 or higher)
- Android Studio / VS Code with Flutter extensions
- An Android/iOS device or emulator
-
Clone the repository
git clone https://github.com/yourusername/Weather_App.git cd Weather_App -
Install dependencies
flutter pub get
-
Run the app
flutter run
dependencies:
http: ^1.2.0 # API requests
shared_preferences: ^2.2.2 # Local caching
connectivity_plus: ^6.0.2 # Network status
flutter_spinkit: ^5.2.0 # Loading animationsThe app calculates location coordinates from your student index number:
Index Format: XYZZAAB (e.g., 224045B)
Latitude = 5 + (XY / 10.0) // First 2 digits
Longitude = 79 + (ZZ / 10.0) // Next 2 digits
Example: 224045B
โ Latitude = 5 + (22 / 10.0) = 7.20
โ Longitude = 79 + (40 / 10.0) = 83.00The app uses the free Open-Meteo API (no authentication required):
https://api.open-meteo.com/v1/forecast?latitude={LAT}&longitude={LON}¤t_weather=true
Response includes:
- Temperature (ยฐC)
- Wind speed (km/h)
- Weather code (WMO codes)
- Timestamp
- Online Mode: Fetches fresh data from API and caches it locally
- Offline Mode: Displays cached data with "(cached)" label
- Cache Updates: Automatic timestamp tracking
- Error Handling: Falls back to cache on network errors
// Cache Service stores:
- weatherData: JSON string of weather data
- lastUpdate: Timestamp of last successful fetch- Launch app โ tap "Get Started"
- Enter index (e.g.,
224045B) - Tap "Continue"
- View weather data with:
- Temperature
- Wind speed
- Weather code
- Coordinates
- API URL
- Complete Test Case 1 (to cache data)
- Enable Airplane Mode
- Pull down to refresh OR restart app
- View cached data with "(cached)" label
- Turn off internet before first launch
- Enter index and continue
- See error message: "Could not fetch weather"
- Tap "Try Again" after enabling internet
- Welcome screen with weather icon
- Blue gradient background
- "Get Started" button
- Index number input field
- Format validation (6 digits + letter)
- Pre-filled example:
224045B
- Large temperature display
- Weather icon and description
- Wind speed and weather code
- Coordinates display
- API request URL
- Cached data indicator (when offline)
Color Scheme:
- Primary: Blue shades (#2196F3 family)
- Background: Gradient (blue โ white)
- Cards: White with elevation
- Text: Black87 / White
Typography:
- Headers: Bold, 24-32px
- Body: Regular, 14-16px
- Monospace: API URLs
## Assignment: Personalized Weather Dashboard
### Student Information
- **Index Number**: 224045B
- **Calculated Coordinates**:
- Latitude: 7.20
- Longitude: 83.00
### API Request URLhttps://api.open-meteo.com/v1/forecast?latitude=7.2&longitude=83.0¤t_weather=true
### Screenshots
[Include screenshots of all three pages]
### Reflection
I learned how to integrate REST APIs in Flutter and handle JSON parsing
efficiently. Using shared_preferences taught me how to cache data locally
for offline use. The coordinate generation from my index number was
interesting and showed how logic can drive API customization. I faced
minor challenges with async functions and managing UI updates but
overcame them by using FutureBuilder and setState properly.
flutter clean
flutter pub get- Check internet connection
- Verify coordinates are valid (lat: -90 to 90, lon: -180 to 180)
- Check API URL format
- Check app permissions
- Clear app data and restart
- Verify SharedPreferences initialization
flutter runflutter build apk --releaseflutter testflutter analyzeContributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Your Name
- GitHub: @yourusername
- Email: your.email@example.com
- Open-Meteo for providing free weather API
- Flutter team for the amazing framework
- UI inspiration from realflutternuggets/flutter-weather-app
If you have any questions or need help, please:
- Check the Issues page
- Create a new issue with detailed description
- Contact via email
Made with โค๏ธ using Flutter