Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weather App

A Flutter weather application that allows users to search for current weather conditions in any city worldwide using the OpenWeatherMap API. Log in to OpenWeatherMap to access your API Key and add it to main.dart.

About

This app provides real-time weather information with a clean, modern UI featuring:

  • City Search: Enter any city name to get current weather data
  • Weather Display: View temperature, weather conditions, and descriptive icons
  • Detailed Metrics: See feels-like temperature, humidity, and wind speed
  • Visual Design: Gradient background with Material 3 design elements

Features

  • Real-time weather data from OpenWeatherMap API
  • Temperature display in Celsius
  • Weather condition icons (sun, clouds, rain, snow, etc.)
  • Humidity and wind speed information
  • Error handling for invalid cities and network issues

Getting Started

Prerequisites

  • Flutter SDK ^3.9.2
  • Dart SDK ^3.9.2

Installation

  1. Clone the repository
  2. Install dependencies:
    flutter pub get
  3. Run the app:
    flutter run

Project Structure

lib/
├── main.dart                      # Main app and UI components
├── services/
│   └── weather_service.dart       # API service with HTTP client
└── utils/
    └── weather_icon_helper.dart   # Weather icon mapping utility

test/
├── services/
│   └── weather_service_test.dart  # WeatherService unit tests
├── utils/
│   └── weather_icon_helper_test.dart  # Icon helper unit tests
└── widgets/
    └── weather_home_page_test.dart    # Widget tests

Testing

The app includes comprehensive unit and widget tests using Flutter's testing framework and mocktail for mocking.

Running Tests

flutter test

Test Coverage

Test Suite Tests Description
WeatherService 11 API calls, error handling, URL construction
WeatherIconHelper 12 Icon mapping for all weather conditions
WeatherHomePage 13 Widget rendering and user interactions
Total 36

WeatherService Tests

  • Empty city validation
  • Successful API response (200 status)
  • City not found handling (404 status)
  • Server error handling (500 status)
  • Network exception handling
  • Correct API URL construction
  • City names with spaces

WeatherIconHelper Tests

  • All weather conditions (clear, clouds, rain, drizzle, thunderstorm, snow, mist, fog)
  • Null and empty input handling
  • Case-insensitive matching

Widget Tests

  • App renders correctly
  • Search field displays and accepts input
  • Initial prompt message shown
  • AppBar configuration
  • Gradient background rendering
  • Layout structure verification

Dependencies

Production:

  • http: ^1.6.0 - HTTP client for API requests
  • cupertino_icons: ^1.0.8 - iOS style icons

Development:

  • flutter_test - Flutter testing framework
  • mocktail: ^1.0.4 - Mocking library for tests
  • flutter_lints: ^5.0.0 - Linting rules

API

This app uses the OpenWeatherMap API to fetch weather data.

About

A simple weather application used in the implementation of flutter ci with bitrise

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages