A simple weather application built with Flutter that fetches and displays current weather data based on the user's location or a searched city. The app uses the OpenWeather API for weather data and includes support for location-based services.
- 🌎 Location-based Weather: Automatically detects the user's current location and displays the current weather.
- 🔍 City Search: Allows users to search for the weather in different cities.
- 📅 Current Date & Time: Displays the current date, day, and time.
- 🌦️ Weather Details: Shows temperature, weather description, humidity, and precipitation chances.
- 🌐 Weather Icons: Displays weather icons corresponding to the current conditions.
- 🛰️ Real-Time Updates: Fetches updated weather data for new locations.
Weather Screen | City Search Screen |
---|---|
- Flutter: Cross-platform UI toolkit for building natively compiled applications.
- Dart: Programming language used for Flutter apps.
- Provider: State management solution for managing weather data.
- OpenWeather API: External API service to fetch real-time weather data.
- Flutter SDK: Install Flutter
- Dart SDK: Comes bundled with Flutter.
- OpenWeather API Key: You will need an API key from OpenWeather.
-
Clone the repository:
git clone https://github.com/sayvilahsiav/weather_app.git
-
Navigate to the project directory:
cd weather_app
-
Install the dependencies:
flutter pub get
-
Create a file called
config.dart
in thelib
folder and add your OpenWeather API key:// config.dart const String openWeatherAPIKey = 'YOUR_API_KEY';
-
Run the app:
flutter run
- On launching, the app will automatically detect your location and show the current weather conditions.
- Use the location refresh button in the top-left corner to update your location-based weather information.
- Tap the search button in the top-right corner to search for the weather in a specific city.
- Weather details such as temperature, humidity, and precipitation will be displayed along with relevant weather icons.
This app uses the OpenWeather API to fetch weather data.
To set up the API:
- Sign up for an account on OpenWeather and get an API key.
- Add the key in
config.dart
as described above.
API endpoints used:
- By Location: Fetches weather data based on the user's latitude and longitude.
- By City: Fetches weather data by city name.
Contributions are welcome! If you'd like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature-name
). - Make your changes and commit them (
git commit -m 'Add your message'
). - Push to the branch (
git push origin feature/your-feature-name
). - Open a pull request.