![flutter blocs flutter blocs](https://i.pinimg.com/736x/dd/8d/65/dd8d6576d39a6108224d3c6af4f4b563.jpg)
Reactive programming in flutter helps you propagate changes to the user interface without having to describe how the propagation happens. To understand BLOCs we need a little bit of knowledge about Reactive programming.Īccording to Wikipedia, “Reactive Programming is a declarative programming paradigm concerned with data streams and the propagation of change” In simple terms, it is programming with asynchronous data streams. So this is where the BLOC comes into play.īLOCs helps us separate our logic from the user interface while maintaining flutter reactive model of redrawing/rerendering when a state or in this case when there is a new stream.
![flutter blocs flutter blocs](https://i.ytimg.com/vi/ckh-25iI6Ec/maxresdefault.jpg)
To use trigger a state change/ redraw flutter provides the setState function if you have ever written React this is similar to tState.Ī problem arises when you are building complex applications where you might have multiple setState calls, your logic tightly coupled to the user interface(Widgets) and you might have to deal with unnecessary redraw of a widget can lead to performance issues. Flutter is reactive because it helps us manage the state of those widgets so when the state of any widget changes, it automatic redraws/rerender that widget by itself. Reactive model meaning that Flutter user interface components are made up of widgets and we can build complex user interfaces by composing those widgets. Guidelines/rules in implementing the BLOCīLOC is an acronym for Business Logic Component and was introduced by Google in Google I/O 2018, It provides a more elegant and reusable way of managing state in Flutter applications which takes advantage of flutter’s UI reactive model.A little bit of Reactive Programming, Streams and StreamControllers(Subjects/Observables).Basic knowledge of Reactive Programming(Streams/Observables).Prerequisite Knowledgeįor you get the most out of this tutorial you should have an understanding of the following: I am assuming that for you to be reading this article you are interested in Flutter and want to learn more about it so I will stop all the rave reviews and let’s try to get our hands and heads dirty. Since its release in 2017, it has grown in popularity and it has been adopted by companies like Alibaba in building cross-platform mobile applications.
![flutter blocs flutter blocs](https://miro.medium.com/max/1280/1*e7pryDJF6DhP_c0OmXdB_w.jpeg)
Flutter is a very interesting library/framework for building cross-platform mobile applications, Flutter can also be used to develop desktop and web applications.