Open Weather Map Client

Package that communicates with Open Weather Map to obtain climate data in a model.

Getting Started

pub package

Get the current weather

See the full example at: https://github.com/astudilloalex/flutter-open-weather-map-client/tree/main/example

FutureBuilder<CurrentWeather>(
    future: openWeatherMap.currentWeather(const City(name: 'London')),
    builder: (_, snapshot) {
        if (snapshot.connectionState == ConnectionState.waiting) {
            return const Center(child: CircularProgressIndicator.adaptive());
        }
        if (snapshot.hasError) {
            return ApiErrorCard(apiError: snapshot.error! as ApiError);
        }
        if (!snapshot.hasData) {
            return const Center(
                child: Text(
                'Error obtained data, check internet connection',
                ),
            );
        }
        final CurrentWeather weather = snapshot.data!;
        return Center(
        child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: [
                    Text('City: ${weather.city.name}'),
                    Text('Temperature: ${weather.detail.temperatureCelsius.toStringAsFixed(2)} °C'),
                    Text('Speed: ${weather.wind.speed.toStringAsFixed(2)} m/s'),
                ],
            ),
        );
    },
),

Flutter Open Weather Map Client Example

Libraries

open_weather_map_client