{"id":19519030,"url":"https://github.com/bizz84/open_weather_example_flutter","last_synced_at":"2025-04-06T04:16:25.501Z","repository":{"id":38746402,"uuid":"447628743","full_name":"bizz84/open_weather_example_flutter","owner":"bizz84","description":"Flutter Weather App Example using the OpenWeatherMap API","archived":false,"fork":false,"pushed_at":"2024-04-19T02:52:07.000Z","size":323,"stargazers_count":302,"open_issues_count":2,"forks_count":77,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-30T03:07:29.150Z","etag":null,"topics":["app-architecture","flutter","rest-api"],"latest_commit_sha":null,"homepage":"https://codewithandrea.com/","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bizz84.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-13T14:24:59.000Z","updated_at":"2025-02-18T07:52:31.000Z","dependencies_parsed_at":"2024-11-18T01:47:02.864Z","dependency_job_id":null,"html_url":"https://github.com/bizz84/open_weather_example_flutter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bizz84%2Fopen_weather_example_flutter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bizz84%2Fopen_weather_example_flutter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bizz84%2Fopen_weather_example_flutter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bizz84%2Fopen_weather_example_flutter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bizz84","download_url":"https://codeload.github.com/bizz84/open_weather_example_flutter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247430966,"owners_count":20937875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["app-architecture","flutter","rest-api"],"created_at":"2024-11-11T00:15:57.204Z","updated_at":"2025-04-06T04:16:25.454Z","avatar_url":"https://github.com/bizz84.png","language":"Dart","funding_links":[],"categories":["Examples"],"sub_categories":[],"readme":"# Flutter Weather App Example\n\nAn example Flutter weather app using the [OpenWeatherMap API](https://openweathermap.org/api).\n\n\u003cimg src=\"https://github.com/bizz84/open_weather_example_flutter/blob/main/.github/images/weather-forecast.png?raw=true\" alt=\"Flutter Weather App Preview\" width=50% height=50%\u003e\n\n## Related Tutorials\n\n- [Flutter App Architecture: The Repository Pattern](https://codewithandrea.com/articles/flutter-repository-pattern/)\n\n## Supported Features\n\n- [x] Current weather (condition and temperature)\n- [x] 5-day weather forecast\n- [x] Search by city\n\n## App Architecture\n\nThe app is composed by three main layers.\n\n### Data Layer\n\nThe data layer contains a single `HttpWeatherRepository` that is used to fetch weather data from the [OpenWeatherMap API](https://openweathermap.org/api).\n\nThe data is then parsed (using Freezed) and returned using **type-safe** entity classes (`Weather` and `Forecast`).\n\nFor more info about this, read this tutorial:\n\n- [Flutter App Architecture: The Repository Pattern](https://codewithandrea.com/articles/flutter-repository-pattern/)\n\nFor more info about the project structure, read this:\n\n- [Flutter Project Structure: Feature-first or Layer-first?](https://codewithandrea.com/articles/flutter-project-structure/)\n\n### Application Layer\n\nThis contains some providers that are used to fetch and cache the data from the `HttpWeatherRepository`.\n\n```dart\n// current city stored in the search box in the UI\nfinal cityProvider = StateProvider\u003cString\u003e((ref) {\n  return 'London';\n});\n\n// provider to fetch the current weather\nfinal currentWeatherProvider =\n    FutureProvider.autoDispose\u003cWeatherData\u003e((ref) async {\n  final city = ref.watch(cityProvider);\n  final weather =\n      await ref.watch(weatherRepositoryProvider).getWeather(city: city);\n  return WeatherData.from(weather);\n});\n\n// provider to fetch the hourly weather\nfinal hourlyWeatherProvider =\n    FutureProvider.autoDispose\u003cForecastData\u003e((ref) async {\n  final city = ref.watch(cityProvider);\n  final forecast =\n      await ref.watch(weatherRepositoryProvider).getForecast(city: city);\n  return ForecastData.from(forecast);\n});\n```\n\n### Presentation Layer\n\nThis layer holds all the widgets, which fetch the data from the `FutureProvider`s above and map the resulting `AsyncValue` objects to the appropriate UI states (data, loading, error).\n\n## Packages in use\n\n- [riverpod](https://pub.dev/packages/riverpod) for state management\n- [freezed](https://pub.dev/packages/freezed) for code generation\n- [http](https://pub.dev/packages/http) for talking to the REST API\n- [cached_network_image](https://pub.dev/packages/cached_network_image) for caching images\n- [mocktail](https://pub.dev/packages/mocktail) for testing\n\n## About the OpenStreetMap weather API\n\nThe app shows data from the following endpoints:\n\n- [Current Weather Data](https://openweathermap.org/current)\n- [Weather Fields in API Response](https://openweathermap.org/current#parameter)\n- [5 day weather forecast](https://openweathermap.org/forecast5)\n- [Weather Conditions](https://openweathermap.org/weather-conditions)\n\n**Note**: to use the API you'll need to register an account and obtain your own API key. This can be set via `--dart-define` or inside `lib/src/api/api_keys.dart`.\n\n### [LICENSE: MIT](LICENSE.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbizz84%2Fopen_weather_example_flutter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbizz84%2Fopen_weather_example_flutter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbizz84%2Fopen_weather_example_flutter/lists"}