open_weather_map_client 1.0.2 copy "open_weather_map_client: ^1.0.2" to clipboard
open_weather_map_client: ^1.0.2 copied to clipboard

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

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

3
likes
105
pub points
0%
popularity

Publisher

verified publisheralexastudillo.com

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-2-Clause-Views (LICENSE)

Dependencies

flutter, http

More

Packages that depend on open_weather_map_client