GithubHelp home page GithubHelp logo

cemtitor / weather_bloc Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 149 KB

Weather app will pull live weather data from the public OpenMeteo API and demonstrate how to separate our application into layers (data, repository, business logic, and presentation)

Kotlin 0.15% Swift 0.47% Objective-C 0.04% Dart 99.34%
application-layer bloc hydratedbloc openmeteo-api creating-package

weather_bloc's Introduction

weather_bloc

Weather app that how to manage multiple cubits to implement dynamic theming, pull-to-refresh, and much more. Our weather app will pull live weather data from the public OpenMeteo API and demonstrate how to separate our application into layers (data, repository, feature(business logic, and presentation) ).

flutter_weather

Project Requirements

Our app should let users

  • Search for a city on a dedicated search page

  • See a pleasant depiction of the weather data returned by Open Meteo API

  • Change the units displayed (metric vs imperial)

  • Additionally,

  • The theme of the application should reflect the weather for the chosen city

  • Application state should persist across sessions: i.e., the app should remember its state after closing and reopening it (using HydratedBloc)

Key Concepts

  • Observe state changes with BlocObserver
  • BlocProvider, Flutter widget that provides a bloc to its children
  • BlocBuilder, Flutter widget that handles building the widget in response to new states
  • Prevent unnecessary rebuilds with Equatable
  • RepositoryProvider, a Flutter widget that provides a repository to its children
  • BlocListener, a Flutter widget that invokes the listener code in response to state changes in the bloc
  • MultiBlocProvider, a Flutter widget that merges multiple BlocProvider widgets into one
  • BlocConsumer, a Flutter widget that exposes a builder and listener in order to react to new states
  • HydratedBloc to manage and persist state

Architecture

In this tutorial, here's what these layers will do:

  • Data: retrieve raw weather data from the API
  • Repository: abstract the data layer and expose domain models for the application to consume
  • Feature :
    • Business Logic: manage the state of each feature (unit information, city details, themes, etc.)
    • Presentation: display weather information and collect input from users (settings page, search page etc.)

Repository Layer:

The goal of our repository layer is to abstract our data layer and facilitate(kolaylastırmak) communication with the bloc layer. In doing this, the rest of our code base depends ONLY ON functions EXPOSED BY our repository layer INSTEAD OF specific data provider implementations. This allows us to change data providers WITHOUT DISRUPTING any of the application-level code. For example, if we DECIDE to migrate away from metaweather, we should BE ABLE TO create a new API client and swap it out WITHOUT HAVING TO MAKE CHANGES to the public API of the repository or application layers.

weather_bloc's People

Contributors

cemtitor avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.