{"id":8087,"date":"2023-06-06T12:54:10","date_gmt":"2023-06-06T06:54:10","guid":{"rendered":"https:\/\/jp.polygontech.xyz\/?p=8087"},"modified":"2023-06-11T14:26:33","modified_gmt":"2023-06-11T08:26:33","slug":"flutter-bloc-concepts-benefits-architecture","status":"publish","type":"post","link":"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/","title":{"rendered":"Exploring Flutter Bloc: Concepts, Benefits, and Architecture"},"content":{"rendered":"<p><div class=\"fusion-fullwidth fullwidth-box fusion-builder-row-1 fusion-flex-container nonhundred-percent-fullwidth non-hundred-percent-height-scrolling\" style=\"--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-flex-wrap:wrap;\" ><div class=\"fusion-builder-row fusion-row fusion-flex-align-items-flex-start fusion-flex-content-wrap\" style=\"max-width:1372.8px;margin-left: calc(-4% \/ 2 );margin-right: calc(-4% \/ 2 );\"><div class=\"fusion-layout-column fusion_builder_column fusion-builder-column-0 fusion_builder_column_1_1 1_1 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:100%;--awb-margin-top-large:20px;--awb-spacing-right-large:1.92%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:1.92%;--awb-width-medium:100%;--awb-order-medium:0;--awb-spacing-right-medium:1.92%;--awb-spacing-left-medium:1.92%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;\"><div class=\"fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column\"><div class=\"fusion-image-element \" style=\"text-align:center;--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);\"><span class=\" fusion-imageframe imageframe-none imageframe-1 hover-type-none\" style=\"border-radius:8px;\"><img decoding=\"async\" width=\"1920\" height=\"480\" title=\"Flutter-Bloc-Concepts-Benefits-Architecture\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%271920%27%20height%3D%27480%27%20viewBox%3D%270%200%201920%20480%27%3E%3Crect%20width%3D%271920%27%20height%3D%27480%27%20fill-opacity%3D%220%22%2F%3E%3C%2Fsvg%3E\" data-orig-src=\"https:\/\/jp.polygontech.xyz\/wp-content\/uploads\/2023\/06\/Flutter-Bloc-Concepts-Benefits-Architecture-1.png\" alt class=\"lazyload img-responsive wp-image-8079\"\/><\/span><\/div><\/div><\/div><\/div><\/div><div class=\"fusion-fullwidth fullwidth-box fusion-builder-row-2 fusion-flex-container nonhundred-percent-fullwidth non-hundred-percent-height-scrolling\" style=\"--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-flex-wrap:wrap;\" ><div class=\"fusion-builder-row fusion-row fusion-flex-align-items-flex-start fusion-flex-content-wrap\" style=\"max-width:1372.8px;margin-left: calc(-4% \/ 2 );margin-right: calc(-4% \/ 2 );\"><div class=\"fusion-layout-column fusion_builder_column fusion-builder-column-1 fusion_builder_column_1_1 1_1 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:100%;--awb-margin-top-large:20px;--awb-spacing-right-large:1.92%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:1.92%;--awb-width-medium:100%;--awb-order-medium:0;--awb-spacing-right-medium:1.92%;--awb-spacing-left-medium:1.92%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;\"><div class=\"fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column\"><div class=\"fusion-text fusion-text-1\" style=\"--awb-font-size:var(--awb-typography4-font-size);--awb-line-height:var(--awb-typography4-line-height);--awb-letter-spacing:var(--awb-typography4-letter-spacing);--awb-text-transform:var(--awb-typography4-text-transform);--awb-text-font-family:var(--awb-typography4-font-family);--awb-text-font-weight:var(--awb-typography4-font-weight);--awb-text-font-style:var(--awb-typography4-font-style);\"><p>Good architecture is very important in every good building as well as a good application. When building an application without proper architecture you will end up in a state where everything is messed up. If you don\u2019t follow a proper architecture for your application you will lose control of your application like maintainability, testability, and scalability. In this guide, we will talk about Blocs. Bloc is not just a state management system, it\u2019s also an architectural design pattern that helps you to build production-level applications.<\/p>\n<\/div><\/div><\/div><div class=\"fusion-layout-column fusion_builder_column fusion-builder-column-2 fusion_builder_column_1_1 1_1 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:100%;--awb-margin-top-large:20px;--awb-spacing-right-large:1.92%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:1.92%;--awb-width-medium:100%;--awb-order-medium:0;--awb-spacing-right-medium:1.92%;--awb-spacing-left-medium:1.92%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;\"><div class=\"fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column\"><div class=\"fusion-title title fusion-title-1 fusion-sep-none fusion-title-text fusion-title-size-two\" style=\"--awb-text-color:var(--awb-color8);\"><h2 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:40;line-height:1.5;\">What is Flutter Bloc?<\/h2><\/div><div class=\"fusion-text fusion-text-2\" style=\"--awb-font-size:var(--awb-typography4-font-size);--awb-line-height:var(--awb-typography4-line-height);--awb-letter-spacing:var(--awb-typography4-letter-spacing);--awb-text-transform:var(--awb-typography4-text-transform);--awb-text-font-family:var(--awb-typography4-font-family);--awb-text-font-weight:var(--awb-typography4-font-weight);--awb-text-font-style:var(--awb-typography4-font-style);\"><p>Flutter Bloc is a state management library for Flutter. It is a reactive state management library that helps in separating the business logic from the presentation layer of an application. This makes your code easier to read, understand and debug.<\/p>\n<\/div><\/div><\/div><div class=\"fusion-layout-column fusion_builder_column fusion-builder-column-3 fusion_builder_column_1_1 1_1 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:100%;--awb-margin-top-large:20px;--awb-spacing-right-large:1.92%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:1.92%;--awb-width-medium:100%;--awb-order-medium:0;--awb-spacing-right-medium:1.92%;--awb-spacing-left-medium:1.92%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;\"><div class=\"fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column\"><div class=\"fusion-title title fusion-title-2 fusion-sep-none fusion-title-text fusion-title-size-two\" style=\"--awb-text-color:var(--awb-color8);\"><h2 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:40;line-height:1.5;\">Why Flutter Bloc?<\/h2><\/div><div class=\"fusion-text fusion-text-3\" style=\"--awb-font-size:var(--awb-typography4-font-size);--awb-line-height:var(--awb-typography4-line-height);--awb-letter-spacing:var(--awb-typography4-letter-spacing);--awb-text-transform:var(--awb-typography4-text-transform);--awb-text-font-family:var(--awb-typography4-font-family);--awb-text-font-weight:var(--awb-typography4-font-weight);--awb-text-font-style:var(--awb-typography4-font-style);\"><p>There are many state management solutions and deciding which one to use can be a daunting task. There is no one perfect state management solution! What&#8217;s important is that you pick the one that works best for your team and your project.<\/p>\n<ul>\n<li>It is easy to learn and use. The Flutter Bloc documentation is clear and concise and there are many tutorials available online.<\/li>\n<li>It is powerful and scalable. Flutter Bloc can handle complex applications with a large number of states.<\/li>\n<li>It is reactive. Flutter Bloc updates the state of the application automatically in response to events.<\/li>\n<li>It is well-tested and maintained. The Flutter Bloc team is committed to providing a stable and reliable library.<\/li>\n<\/ul>\n<\/div><div class=\"fusion-title title fusion-title-3 fusion-sep-none fusion-title-text fusion-title-size-two\" style=\"--awb-text-color:var(--awb-color8);\"><h2 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:40;line-height:1.5;\">Flutter Bloc Architecture<\/h2><\/div><div class=\"fusion-image-element \" style=\"--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);\"><span class=\" fusion-imageframe imageframe-none imageframe-2 hover-type-none\" style=\"border-radius:8px;\"><img decoding=\"async\" width=\"919\" height=\"281\" alt=\"Flutter Bloc\" title=\"image26\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%27919%27%20height%3D%27281%27%20viewBox%3D%270%200%20919%20281%27%3E%3Crect%20width%3D%27919%27%20height%3D%27281%27%20fill-opacity%3D%220%22%2F%3E%3C%2Fsvg%3E\" data-orig-src=\"https:\/\/jp.polygontech.xyz\/wp-content\/uploads\/2023\/06\/image26.png\" class=\"lazyload img-responsive wp-image-8057\"\/><\/span><\/div><div class=\"fusion-text fusion-text-4\"><p>Using the bloc library allows us to separate our application into three layers:<\/p>\n<ul>\n<li>Presentation<\/li>\n<li>Business Logic<\/li>\n<li>Data<\/li>\n<\/ul>\n<div>\n<p style=\"padding-left: 80px;\">-&gt; Repository<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 80px;\">-&gt; Data Provider<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div><div class=\"fusion-title title fusion-title-4 fusion-sep-none fusion-title-text fusion-title-size-three\" style=\"--awb-text-color:var(--awb-color8);\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\">UI (Presentation)<\/h3><\/div><div class=\"fusion-text fusion-text-5\"><p>The presentation layer in Flutter is the layer that is responsible for rendering the UI and responding to user input. It is the layer that is closest to the user and is responsible for making the app look and feel good.<\/p>\n<p>The presentation layer is made up of widgets, which are small, reusable components that can be combined to create complex interfaces. Widgets are responsible for drawing themselves on the screen and responding to user input.<\/p>\n<\/div><div class=\"fusion-title title fusion-title-5 fusion-sep-none fusion-title-text fusion-title-size-three\" style=\"--awb-text-color:var(--awb-color8);\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\">Bloc (Business Logic Layer)<\/h3><\/div><div class=\"fusion-text fusion-text-6\"><p>The business logic layer is the bridge between the user interface (presentation layer) and the data layer. The business logic layer is notified of events\/actions from the presentation layer and then communicates with the repository to build a new state for the presentation layer to consume.<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-1 > .CodeMirror, .fusion-syntax-highlighter-1 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-1 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-1 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-1 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_1\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_1\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_1\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">class BusinessLogicComponent extends Bloc<MyEvent, MyState> { BusinessLogicComponent(this.repository) { on<AppStarted>((event, emit) { try { final data = await repository.getAllDataThatMeetsRequirements(); emit(Success(data)); } catch (error) { emit(Failure(error)); } }); } final Repository repository; }<\/textarea><\/div><div class=\"fusion-title title fusion-title-6 fusion-sep-none fusion-title-text fusion-title-size-three\" style=\"--awb-text-color:var(--awb-color8);\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\"><div><\/div>\n<div><\/div>\n<p>Data Layer<\/h3><\/div><div class=\"fusion-text fusion-text-7\"><p>This layer is the lowest level of the application and interacts with databases, network requests, and other asynchronous data sources.<\/p>\n<p>The data layer can be split into two parts:<\/p>\n<ul>\n<li>Data Provider<\/li>\n<li>Repository<\/li>\n<\/ul>\n<\/div><div class=\"fusion-title title fusion-title-7 fusion-sep-none fusion-title-text fusion-title-size-four\" style=\"--awb-text-color:var(--awb-color8);\"><h4 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:24;line-height:1.5;\"><div><\/div>\n<p>Data Provider<\/h4><\/div><div class=\"fusion-text fusion-text-8\"><p>The data provider is a layer that provides access to data. It can be used to store data in memory, in a file, or a database. It can also be used to fetch data from an external source, such as a web service.<\/p>\n<p>There are many different types of data providers in Dart. Some of the most common types include:<\/p>\n<\/div><div class=\"fusion-title title fusion-title-8 fusion-sep-none fusion-title-text fusion-title-size-five\" style=\"--awb-text-color:var(--awb-color8);\"><h5 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:20;line-height:1.5;\">In-memory Data Providers<\/h5><\/div><div class=\"fusion-text fusion-text-9\"><p>These providers store data in memory. They are easy to use and fast, but they can only store a limited amount of data.<\/p>\n<\/div><div class=\"fusion-title title fusion-title-9 fusion-sep-none fusion-title-text fusion-title-size-five\" style=\"--awb-text-color:var(--awb-color8);\"><h5 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:20;line-height:1.5;\">File Data Providers<\/h5><\/div><div class=\"fusion-text fusion-text-10\"><p>These providers store data in files. They can store a large amount of data, but they are not as fast as in-memory providers.<\/p>\n<\/div><div class=\"fusion-title title fusion-title-10 fusion-sep-none fusion-title-text fusion-title-size-five\" style=\"--awb-text-color:var(--awb-color8);\"><h5 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:20;line-height:1.5;\">Database Data Providers<\/h5><\/div><div class=\"fusion-text fusion-text-11\"><p>These providers store data in a database. They can store a very large amount of data and are very fast, but they can be more complex to use than other types of providers.<\/p>\n<\/div><div class=\"fusion-title title fusion-title-11 fusion-sep-none fusion-title-text fusion-title-size-five\" style=\"--awb-text-color:var(--awb-color8);\"><h5 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:20;line-height:1.5;\">Web Service Data Providers<\/h5><\/div><div class=\"fusion-text fusion-text-12\"><p>These providers fetch data from an external web service. They are easy to use and can be used to fetch data from any web service, but they can be slower than other types of providers.<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-2 > .CodeMirror, .fusion-syntax-highlighter-2 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-2 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-2 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-2 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_2\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_2\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_2\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">class DataProvider {\nFuture<RawData> readData() async {\n\t\/\/ Read from DB or make network request etc.\n     }\n}<\/textarea><\/div><div class=\"fusion-title title fusion-title-12 fusion-sep-none fusion-title-text fusion-title-size-four\" style=\"--awb-text-color:var(--awb-color8);\"><h4 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:24;line-height:1.5;\"><div><\/div>\n<p>Repository<\/h4><\/div><div class=\"fusion-text fusion-text-13\"><p>This layer contains one or more than one Data Providers. Actually, the repository layer is a wrapper around one or more data providers with which the Bloc Layer communicates.<\/p>\n<p>&nbsp;<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-3 > .CodeMirror, .fusion-syntax-highlighter-3 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-3 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-3 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-3 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_3\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_3\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_3\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">class Repository {\n    final DataProviderA dataProviderA;\n    final DataProviderB dataProviderB;\n\n    Future<Data> getAllDataThatMeetsRequirements() async {\n        final RawDataA dataSetA = await dataProviderA.readData();\n        final RawDataB dataSetB = await dataProviderB.readData();\n\n        final Data filteredData = _filterData(dataSetA, dataSetB);\n        return filteredData;\n    }\n}<\/textarea><\/div><div class=\"fusion-title title fusion-title-13 fusion-sep-none fusion-title-text fusion-title-size-two\" style=\"--awb-text-color:var(--awb-color8);\"><h2 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:40;line-height:1.5;\"><div><\/div>\n<p>Core Concepts of Flutter Bloc:<\/h2><\/div><div class=\"fusion-title title fusion-title-14 fusion-sep-none fusion-title-text fusion-title-size-three\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\">Streams<\/h3><\/div><div class=\"fusion-text fusion-text-14\"><p>A stream is a sequence of data elements that are continuously generated or received over time.If you&#8217;re unfamiliar with Streams just think of a pipe with water flowing through it. The pipe is the Stream and the water is the asynchronous data.<\/p>\n<\/div><div class=\"fusion-title title fusion-title-15 fusion-sep-none fusion-title-text fusion-title-size-three\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\">Events<\/h3><\/div><div class=\"fusion-text fusion-text-15\"><p>Events are often used to trigger actions in a computer program. For example, when a user clicks a button in UI, an event is generated. This event can then be used to call a function or to change the state of the program.<\/p>\n<\/div><div class=\"fusion-title title fusion-title-16 fusion-sep-none fusion-title-text fusion-title-size-three\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\">State<\/h3><\/div><div class=\"fusion-text fusion-text-16\"><p>The state is updated whenever an event is dispatched. The BLoC then emits the new state to all of its subscribers. This allows the subscribers to update their UI in response to changes in the state of the application.<\/p>\n<\/div><div class=\"fusion-title title fusion-title-17 fusion-sep-none fusion-title-text fusion-title-size-two\" style=\"--awb-text-color:var(--awb-color8);\"><h2 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:40;line-height:1.5;\">Let\u2019s Start with Coding<\/h2><\/div><div class=\"fusion-title title fusion-title-18 fusion-sep-none fusion-title-text fusion-title-size-three\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\">Project Overview<\/h3><\/div><div class=\"fusion-text fusion-text-17\"><p>In this tutorial, we are going to build a weather application (following) flutter bloc. Our 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).<\/p>\n<\/div><div class=\"fusion-title title fusion-title-19 fusion-sep-none fusion-title-text fusion-title-size-four\"><h4 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:24;line-height:1.5;\">Step 1: Create a Flutter Project<\/h4><\/div><div class=\"fusion-text fusion-text-18\"><p>Open the terminal and write the command<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-4 > .CodeMirror, .fusion-syntax-highlighter-4 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-4 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-4 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-4 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_4\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_4\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_4\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">flutter create weather_flutter<\/textarea><\/div><div class=\"fusion-title title fusion-title-20 fusion-sep-none fusion-title-text fusion-title-size-four\"><h4 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:24;line-height:1.5;\"><div><\/div>\n<div><\/div>\n<p>Step 2: Package We are using<\/h4><\/div><div class=\"fusion-text fusion-text-19\"><p>Go to <b>pubspec.yaml<\/b> and add flutter_bloc, bloc, http, equatable,hydrated_bloc, and path_provider packages inside dependencies. Equatable overrides == and hashCode for you so you don&#8217;t have to waste your time writing lots of boilerplate code.<\/p>\n<p>&nbsp;<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-5 > .CodeMirror, .fusion-syntax-highlighter-5 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-5 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-5 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-5 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_5\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_5\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_5\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">flutter_bloc: ^8.1.3\nhttp: ^0.13.5\nequatable: ^2.0.5<\/textarea><\/div><div class=\"fusion-title title fusion-title-21 fusion-sep-none fusion-title-text fusion-title-size-four\"><h4 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:24;line-height:1.5;\"><div><\/div>\n<div><\/div>\n<p>Step 3: Project Setup<\/h4><\/div><div class=\"fusion-title title fusion-title-22 fusion-sep-none fusion-title-text fusion-title-size-five\"><h5 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:20;line-height:1.5;\">main.dart<\/h5><\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-6 > .CodeMirror, .fusion-syntax-highlighter-6 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-6 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-6 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-6 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_6\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_6\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_6\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">void main() async {\n WidgetsFlutterBinding.ensureInitialized();\n runApp(\n   WeatherApp(\n     weatherRepository: WeatherRepositoryImpl(),\n   ),\n );\n}<\/textarea><\/div><div class=\"fusion-title title fusion-title-23 fusion-sep-none fusion-title-text fusion-title-size-five\"><h5 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:20;line-height:1.5;\"><div><\/div>\n<div><\/div>\n<div><\/div>\n<p>app.dart<\/h5><\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-7 > .CodeMirror, .fusion-syntax-highlighter-7 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-7 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-7 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-7 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_7\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_7\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_7\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">class WeatherApp extends StatelessWidget {\n final WeatherRepositoryImpl _weatherRepository;\n\n const WeatherApp(\n     {required WeatherRepositoryImpl weatherRepository, super.key})\n     : _weatherRepository = weatherRepository;\n\n @override\n Widget build(BuildContext context) {\n   return RepositoryProvider.value(\n     value: _weatherRepository,\n     child: const WeatherAppView(),\n   );\n }\n}\n\nclass WeatherAppView extends StatelessWidget {\n const WeatherAppView({super.key});\n\n @override\n Widget build(BuildContext context) {\n   final textTheme = Theme.of(context).textTheme;\n   return const MaterialApp(\n     home: WeatherScreen(),\n   );\n }\n}<\/textarea><\/div><div class=\"fusion-title title fusion-title-24 fusion-sep-none fusion-title-text fusion-title-size-five\"><h5 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:20;line-height:1.5;\"><div><\/div>\n<div><\/div>\n<div><\/div>\n<p>weather_screen.dart<\/h5><\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-8 > .CodeMirror, .fusion-syntax-highlighter-8 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-8 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-8 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-8 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_8\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_8\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_8\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">class WeatherScreen extends StatelessWidget {\n const WeatherScreen({Key? key}) : super(key: key);\n\n @override\n Widget build(BuildContext context) {\n   return BlocProvider(\n     create: (context) => WeatherBloc(context.read<WeatherRepositoryImpl>()),\n     child: const WeatherView(),\n   );\n }\n}\n\nclass WeatherView extends StatefulWidget {\n const WeatherView({Key? key}) : super(key: key);\n\n @override\n State<WeatherView> createState() => _WeatherViewState();\n}\n\nclass _WeatherViewState extends State<WeatherView> {\n Future<void> getRefresh() async {}\n\n @override\n Widget build(BuildContext context) {\n   return Scaffold(\n     appBar: AppBar(\n       title: const Text('Flutter Weather'),\n       actions: [\n         IconButton(\n           icon: const Icon(Icons.search),\n           onPressed: () async {\n             var result = await Navigator.of(context).push(\n               SearchScreen.route(),\n             );\n             if (result != null && mounted) {\n               context.read<WeatherBloc>().add(GetWeather(city: result));\n             }\n           },\n         ),\n       ],\n     ),\n     body: SafeArea(\n       child: Center(\n         child: BlocConsumer<WeatherBloc, WeatherState>(\n           listener: (context, state) {},\n           builder: (context, state) {\n             switch (state.status) {\n               case Status.initial:\n                 return const WeatherEmpty();\n               case Status.failed:\n                 return const WeatherError();\n               case Status.loading:\n                 return const WeatherLoading();\n               case Status.success:\n                 return WeatherPopulated(\n                   weather: state.weather!,\n                   units: state.temperatureUnits,\n                   onRefresh: () {\n                     return getRefresh();\n                   },\n                 );\n             }\n           },\n         ),\n       ),\n     ),\n   );\n }\n}<\/textarea><\/div><div class=\"fusion-title title fusion-title-25 fusion-sep-none fusion-title-text fusion-title-size-six\"><h6 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:18;--minFontSize:18;line-height:1.5;\"><div><\/div>\n<div><\/div>\n<div><\/div>\n<p>WeatherEmpty<\/h6><\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-9 > .CodeMirror, .fusion-syntax-highlighter-9 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-9 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-9 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-9 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_9\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_9\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_9\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">class WeatherEmpty extends StatelessWidget {\n const WeatherEmpty({super.key});\n\n @override\n Widget build(BuildContext context) {\n   final theme = Theme.of(context);\n   return Column(\n     mainAxisSize: MainAxisSize.min,\n     children: [\n       const Text('Cityscape Emoji', style: TextStyle(fontSize: 64)),\n       Text(\n         'Please Select a City!',\n         style: theme.textTheme.headlineSmall,\n       ),\n     ],\n   );\n }\n}<\/textarea><\/div><div class=\"fusion-title title fusion-title-26 fusion-sep-none fusion-title-text fusion-title-size-six\"><h6 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:18;--minFontSize:18;line-height:1.5;\"><div><\/div>\n<div><\/div>\n<div><\/div>\n<p>WeatherError<\/h6><\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-10 > .CodeMirror, .fusion-syntax-highlighter-10 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-10 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-10 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-10 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_10\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_10\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_10\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">class WeatherError extends StatelessWidget {\n const WeatherError({super.key});\n\n @override\n Widget build(BuildContext context) {\n   final theme = Theme.of(context);\n   return Column(\n     mainAxisSize: MainAxisSize.min,\n     children: [\n       const Text('See No Evil Monkey Emoji', style: TextStyle(fontSize: 64)),\n       Text(\n         'Something went wrong!',\n         style: theme.textTheme.headlineSmall,\n       ),\n     ],\n   );\n }\n}<\/textarea><\/div><div class=\"fusion-title title fusion-title-27 fusion-sep-none fusion-title-text fusion-title-size-six\"><h6 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:18;--minFontSize:18;line-height:1.5;\"><div><\/div>\n<div><\/div>\n<div><\/div>\n<p>WeatherLoading<\/h6><\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-11 > .CodeMirror, .fusion-syntax-highlighter-11 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-11 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-11 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-11 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_11\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_11\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_11\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">class WeatherLoading extends StatelessWidget {\n const WeatherLoading({super.key});\n\n @override\n Widget build(BuildContext context) {\n   final theme = Theme.of(context);\n   return Column(\n     mainAxisSize: MainAxisSize.min,\n     children: [\n       const Text('\u26c5', style: TextStyle(fontSize: 64)),\n       Text(\n         'Loading Weather',\n         style: theme.textTheme.headlineSmall,\n       ),\n       const Padding(\n         padding: EdgeInsets.all(16),\n         child: CircularProgressIndicator(),\n       ),\n     ],\n   );\n }\n}<\/textarea><\/div><div class=\"fusion-title title fusion-title-28 fusion-sep-none fusion-title-text fusion-title-size-six\"><h6 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:18;--minFontSize:18;line-height:1.5;\"><div><\/div>\n<div><\/div>\n<div><\/div>\n<p>weather_populated.dart<\/h6><\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-12 > .CodeMirror, .fusion-syntax-highlighter-12 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-12 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-12 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-12 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_12\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_12\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_12\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">class WeatherPopulated extends StatelessWidget {\n const WeatherPopulated({\n   required this.weather,\n   required this.units,\n   required this.onRefresh,\n   super.key,\n });\n\n final Weather weather;\n final TemperatureUnits units;\n final ValueGetter<Future<void>> onRefresh;\n\n \/\/ final Function<void> onRefresh;\n\n @override\n Widget build(BuildContext context) {\n   final theme = Theme.of(context);\n   return Stack(\n     children: [\n       _WeatherBackground(),\n       RefreshIndicator(\n         onRefresh: onRefresh,\n         child: SingleChildScrollView(\n           physics: const AlwaysScrollableScrollPhysics(),\n           clipBehavior: Clip.none,\n           child: Center(\n             child: Column(\n               children: [\n                 const SizedBox(height: 48),\n                 _WeatherIcon(condition: weather.condition),\n                 Text(\n                   weather.location,\n                   style: theme.textTheme.displayMedium?.copyWith(\n                     fontWeight: FontWeight.w200,\n                   ),\n                 ),\n                 Text(\n                   weather.formattedTemperature(units),\n                   style: theme.textTheme.displaySmall?.copyWith(\n                     fontWeight: FontWeight.bold,\n                   ),\n                 ),\n                 \/\/ Text(\n                 \/\/   '''Last Updated at ${TimeOfDay.fromDateTime(weather.).format(context)}''',\n                 \/\/ ),\n               ],\n             ),\n           ),\n         ),\n       ),\n     ],\n   );\n }\n}\n\nclass _WeatherIcon extends StatelessWidget {\n const _WeatherIcon({required this.condition});\n\n static const _iconSize = 75.0;\n\n final WeatherCondition condition;\n\n @override\n Widget build(BuildContext context) {\n   return Text(\n     condition.toEmoji,\n     style: const TextStyle(fontSize: _iconSize),\n   );\n }\n}\n\nextension on WeatherCondition {\n String get toEmoji {\n   switch (this) {\n     case WeatherCondition.clear:\n       return 'Sun Emoji';\n     case WeatherCondition.rainy:\n       return 'Rainy Cloud Emoji';\n     case WeatherCondition.cloudy:\n       return 'Cloud Emoni';\n     case WeatherCondition.snowy:\n       return 'Cloud with Snow ';\n     case WeatherCondition.unknown:\n       return '\u2753';\n   }\n }\n}\n\nclass _WeatherBackground extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n   final color = Theme.of(context).primaryColor;\n   return SizedBox.expand(\n     child: DecoratedBox(\n       decoration: BoxDecoration(\n         gradient: LinearGradient(\n           begin: Alignment.topCenter,\n           end: Alignment.bottomCenter,\n           stops: const [0.25, 0.75, 0.90, 1.0],\n           colors: [\n             color,\n             color.brighten(),\n             color.brighten(33),\n             color.brighten(50),\n           ],\n         ),\n       ),\n     ),\n   );\n }\n}\n\nextension on Color {\n Color brighten([int percent = 10]) {\n   assert(\n     1 <= percent && percent <= 100,\n     'percentage must be between 1 and 100',\n   );\n   final p = percent \/ 100;\n   return Color.fromARGB(\n     alpha,\n     red + ((255 - red) * p).round(),\n     green + ((255 - green) * p).round(),\n     blue + ((255 - blue) * p).round(),\n   );\n }\n}\n\nextension on Weather {\n String formattedTemperature(TemperatureUnits units) {\n   return '''${temperature.toStringAsPrecision(2)}\u00b0${units.isCelsius ? 'C' : 'F'}''';\n }\n}<\/textarea><\/div><div class=\"fusion-title title fusion-title-29 fusion-sep-none fusion-title-text fusion-title-size-six\"><h6 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:18;--minFontSize:18;line-height:1.5;\"><div><\/div>\n<div><\/div>\n<div><\/div>\n<p>screen_search.dart<\/h6><\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-13 > .CodeMirror, .fusion-syntax-highlighter-13 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-13 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-13 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-13 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_13\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_13\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_13\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">class SearchScreen extends StatefulWidget {\n const SearchScreen({Key? key}) : super(key: key);\n\n static Route<String> route() {\n   return MaterialPageRoute(builder: (_) => const SearchScreen());\n }\n\n @override\n State<SearchScreen> createState() => _SearchScreenState();\n}\n\nclass _SearchScreenState extends State<SearchScreen> {\n final TextEditingController _textController = TextEditingController();\n\n String get _text => _textController.text;\n\n @override\n void dispose() {\n   _textController.dispose();\n   super.dispose();\n }\n\n @override\n Widget build(BuildContext context) {\n   return Scaffold(\n     appBar: AppBar(title: const Text('City Search')),\n     body: Row(\n       children: [\n         Expanded(\n           child: Padding(\n             padding: const EdgeInsets.all(8),\n             child: TextField(\n               controller: _textController,\n               decoration: const InputDecoration(\n                 labelText: 'City',\n                 hintText: 'Chicago',\n               ),\n             ),\n           ),\n         ),\n         IconButton(\n           key: const Key('searchPage_search_iconButton'),\n           icon: const Icon(Icons.search, semanticLabel: 'Submit'),\n           onPressed: () => Navigator.of(context).pop(_text),\n         )\n       ],\n     ),\n   );\n }\n}<\/textarea><\/div><\/div><\/div><\/div><\/div><div class=\"fusion-fullwidth fullwidth-box fusion-builder-row-3 fusion-flex-container nonhundred-percent-fullwidth non-hundred-percent-height-scrolling\" style=\"--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-flex-wrap:wrap;\" ><div class=\"fusion-builder-row fusion-row fusion-flex-align-items-flex-start fusion-flex-content-wrap\" style=\"max-width:1372.8px;margin-left: calc(-4% \/ 2 );margin-right: calc(-4% \/ 2 );\"><div class=\"fusion-layout-column fusion_builder_column fusion-builder-column-4 fusion_builder_column_1_1 1_1 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:100%;--awb-margin-top-large:20px;--awb-spacing-right-large:1.92%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:1.92%;--awb-width-medium:100%;--awb-order-medium:0;--awb-spacing-right-medium:1.92%;--awb-spacing-left-medium:1.92%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;\"><div class=\"fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column\"><div class=\"fusion-title title fusion-title-30 fusion-sep-none fusion-title-text fusion-title-size-three\" style=\"--awb-text-color:var(--awb-color8);\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\">Final UI:<\/h3><\/div><div class=\"fusion-builder-row fusion-builder-row-inner fusion-row fusion-flex-align-items-flex-start fusion-flex-content-wrap\" style=\"width:104% !important;max-width:104% !important;margin-left: calc(-4% \/ 2 );margin-right: calc(-4% \/ 2 );\"><div class=\"fusion-layout-column fusion_builder_column_inner fusion-builder-nested-column-0 fusion_builder_column_inner_1_5 1_5 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:20%;--awb-margin-top-large:20px;--awb-spacing-right-large:9.6%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:9.6%;--awb-width-medium:20%;--awb-order-medium:0;--awb-spacing-right-medium:9.6%;--awb-spacing-left-medium:9.6%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;\"><div class=\"fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column\"><\/div><\/div><div class=\"fusion-layout-column fusion_builder_column_inner fusion-builder-nested-column-1 fusion_builder_column_inner_1_4 1_4 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:25%;--awb-margin-top-large:20px;--awb-spacing-right-large:7.68%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:7.68%;--awb-width-medium:25%;--awb-order-medium:0;--awb-spacing-right-medium:7.68%;--awb-spacing-left-medium:7.68%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;\"><div class=\"fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column\"><div class=\"fusion-image-element \" style=\"--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);\"><span class=\" fusion-imageframe imageframe-none imageframe-3 hover-type-none\" style=\"border-radius:8px;\"><img decoding=\"async\" width=\"923\" height=\"1999\" title=\"image28\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%27923%27%20height%3D%271999%27%20viewBox%3D%270%200%20923%201999%27%3E%3Crect%20width%3D%27923%27%20height%3D%271999%27%20fill-opacity%3D%220%22%2F%3E%3C%2Fsvg%3E\" data-orig-src=\"https:\/\/jp.polygontech.xyz\/wp-content\/uploads\/2023\/06\/image28.jpg\" alt class=\"lazyload img-responsive wp-image-8070\"\/><\/span><\/div><\/div><\/div><div class=\"fusion-layout-column fusion_builder_column_inner fusion-builder-nested-column-2 fusion_builder_column_inner_1_5 1_5 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:20%;--awb-margin-top-large:20px;--awb-spacing-right-large:9.6%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:9.6%;--awb-width-medium:20%;--awb-order-medium:0;--awb-spacing-right-medium:9.6%;--awb-spacing-left-medium:9.6%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;\"><div class=\"fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column\"><\/div><\/div><div class=\"fusion-layout-column fusion_builder_column_inner fusion-builder-nested-column-3 fusion_builder_column_inner_1_4 1_4 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:25%;--awb-margin-top-large:20px;--awb-spacing-right-large:7.68%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:7.68%;--awb-width-medium:25%;--awb-order-medium:0;--awb-spacing-right-medium:7.68%;--awb-spacing-left-medium:7.68%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;\"><div class=\"fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column\"><div class=\"fusion-image-element \" style=\"--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);\"><span class=\" fusion-imageframe imageframe-none imageframe-4 hover-type-none\" style=\"border-radius:8px;\"><img decoding=\"async\" width=\"923\" height=\"1999\" title=\"image1\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%27923%27%20height%3D%271999%27%20viewBox%3D%270%200%20923%201999%27%3E%3Crect%20width%3D%27923%27%20height%3D%271999%27%20fill-opacity%3D%220%22%2F%3E%3C%2Fsvg%3E\" data-orig-src=\"https:\/\/jp.polygontech.xyz\/wp-content\/uploads\/2023\/06\/image1.jpg\" alt class=\"lazyload img-responsive wp-image-8068\"\/><\/span><\/div><\/div><\/div><\/div><div class=\"fusion-title title fusion-title-31 fusion-sep-none fusion-title-text fusion-title-size-three\" style=\"--awb-text-color:var(--awb-color8);\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\">Data Layer<\/h3><\/div><div class=\"fusion-text fusion-text-20\"><p><span style=\"font-weight: 400;\">Data: Retrieve raw weather data from the API<\/span><\/p>\n<p><b>We&#8217;ll be focusing on two endpoints:<\/b><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<ul>\n<li>https:\/\/geocoding-api.open-meteo.com\/v1\/search?name=$city&amp;count=1 to get a location for a given city name<\/li>\n<li>https:\/\/api.open-meteo.com\/v1\/forecast?latitude=$latitude&amp;longitude=$longitude&amp;current_weather=true to get the weather for a given location<\/li>\n<\/ul>\n<p>Open https:\/\/geocoding-api.open-meteo.com\/v1\/search?name=chicago&amp;count=1 in your browser to see the response for the city of Chicago. We will use the latitude and longitude in the response to hit the weather endpoint.<\/p>\n<p>The latitude\/longitude for Chicago is 41.85003\/-87.65005. Navigate to https:\/\/api.open-meteo.com\/v1\/forecast?latitude=43.0389&amp;longitude=-87.90647&amp;current_weather=true in your browser and you&#8217;ll see the response for weather in Chicago which contains all the data we will need for our app.<\/p>\n<\/div><div class=\"fusion-title title fusion-title-32 fusion-sep-none fusion-title-text fusion-title-size-four\" style=\"--awb-text-color:var(--awb-color8);\"><h4 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:24;line-height:1.5;\">Repository Layer<\/h4><\/div><div class=\"fusion-text fusion-text-21\"><p>The goal of our repository layer is to abstract our data layer and facilitate 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.<\/p>\n<p><b>weather_repository.dart<\/b><\/p>\n<p>Here we just declared the method<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-14 > .CodeMirror, .fusion-syntax-highlighter-14 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-14 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-14 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-14 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_14\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_14\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_14\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">abstract class WeatherRepository {\n Future<Weather> getWeather(String city);\n}<\/textarea><\/div><div class=\"fusion-text fusion-text-22\"><p>&nbsp;<\/p>\n<p>Now Implement the WeatherRepository abstract class on weather_repository_impl<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-15 > .CodeMirror, .fusion-syntax-highlighter-15 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-15 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-15 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-15 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_15\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_15\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_15\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">class WeatherRepositoryImpl extends WeatherRepository {\n final ApiClient _apiClient;\n\n WeatherRepositoryImpl({ApiClient? apiClient})\n     : _apiClient = apiClient ?? ApiClient();\n\n @override\n Future<Weather> getWeather(String city) async {\n   final location = await _apiClient.locationSearch(city);\n   final weather = await _apiClient.getWeather(\n     latitude: location.locationData!.first.latitude!,\n     longitude: location.locationData!.first.longitude!,\n   );\n   return Weather(\n     temperature: weather.temperature!,\n     location: location.locationData!.first.name!,\n     condition: weather.weatherCode!.toInt().toCondition,\n   );\n }\n}\n\nextension on int {\n WeatherCondition get toCondition {\n   switch (this) {\n     case 0:\n       return WeatherCondition.clear;\n     case 1:\n     case 2:\n     case 3:\n     case 45:\n     case 48:\n       return WeatherCondition.cloudy;\n     case 51:\n     case 53:\n     case 55:\n     case 56:\n     case 57:\n     case 61:\n     case 63:\n     case 65:\n     case 66:\n     case 67:\n     case 80:\n     case 81:\n     case 82:\n     case 95:\n     case 96:\n     case 99:\n       return WeatherCondition.rainy;\n     case 71:\n     case 73:\n     case 75:\n     case 77:\n     case 85:\n     case 86:\n       return WeatherCondition.snowy;\n     default:\n       return WeatherCondition.unknown;\n   }\n }\n}<\/textarea><\/div><div class=\"fusion-title title fusion-title-33 fusion-sep-none fusion-title-text fusion-title-size-four\" style=\"--awb-text-color:var(--awb-color8);\"><h4 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:24;line-height:1.5;\"><div><\/div>\n<p>Model<\/h4><\/div><div class=\"fusion-title title fusion-title-34 fusion-sep-none fusion-title-text fusion-title-size-five\" style=\"--awb-text-color:var(--awb-color8);\"><h5 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:20;line-height:1.5;\">CurrentWeather.dart<\/h5><\/div><div class=\"fusion-text fusion-text-23\"><p>We are using three model current_weather.dart, location.dart and weather.dart<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-16 > .CodeMirror, .fusion-syntax-highlighter-16 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-16 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-16 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-16 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_16\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_16\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_16\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">class CurrentWeather {\n double? temperature;\n double? windSpeed;\n String? time;\n int? weatherCode;\n\n CurrentWeather({this.temperature, this.windSpeed, this.time});\n\n CurrentWeather.fromJson(Map<String, dynamic> json) {\n   temperature = json['temperature'];\n   windSpeed = json['windspeed'];\n   time = json['time'];\n   weatherCode = json['weathercode'];\n }\n}<\/textarea><\/div><div class=\"fusion-title title fusion-title-35 fusion-sep-none fusion-title-text fusion-title-size-five\" style=\"--awb-text-color:var(--awb-color8);\"><h5 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:20;line-height:1.5;\"><div><\/div>\n<div><\/div>\n<p>Location.dart<\/h5><\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-17 > .CodeMirror, .fusion-syntax-highlighter-17 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-17 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-17 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-17 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_17\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_17\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_17\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">class Location {\n List<LocationData>? locationData;\n\n Location({this.locationData});\n\n Location.fromJson(Map<String, dynamic> json) {\n   if (json['results'] != null) {\n     locationData = <LocationData>[];\n     json['results'].forEach((v) {\n       locationData!.add(LocationData.fromJson(v));\n     });\n   }\n }\n}\n\nclass LocationData {\n int? id;\n String? name;\n double? latitude;\n double? longitude;\n\n LocationData({this.id, this.name, this.latitude, this.longitude});\n\n LocationData.fromJson(Map<String, dynamic> json) {\n   id = json['id'];\n   name = json['name'];\n   latitude = json['latitude'];\n   longitude = json['longitude'];\n }\n}<\/textarea><\/div><div class=\"fusion-title title fusion-title-36 fusion-sep-none fusion-title-text fusion-title-size-five\" style=\"--awb-text-color:var(--awb-color8);\"><h5 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:20;line-height:1.5;\"><div><\/div>\n<div><\/div>\n<p>weather.dart<\/h5><\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-18 > .CodeMirror, .fusion-syntax-highlighter-18 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-18 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-18 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-18 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_18\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_18\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_18\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">enum WeatherCondition {\n clear,\n rainy,\n cloudy,\n snowy,\n unknown,\n}\n\nenum TemperatureUnits { fahrenheit, celsius }\n\nextension TemperatureUnitsX on TemperatureUnits {\n bool get isFahrenheit => this == TemperatureUnits.fahrenheit;\n\n bool get isCelsius => this == TemperatureUnits.celsius;\n}\n\nclass Weather extends Equatable {\n final String location;\n final double temperature;\n final WeatherCondition condition;\n\n const Weather({\n   required this.location,\n   required this.temperature,\n   required this.condition,\n });\n\n @override\n List<Object?> get props => [location, temperature, condition];\n}<\/textarea><\/div><\/div><\/div><\/div><\/div><div class=\"fusion-fullwidth fullwidth-box fusion-builder-row-4 fusion-flex-container nonhundred-percent-fullwidth non-hundred-percent-height-scrolling\" style=\"--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-flex-wrap:wrap;\" ><div class=\"fusion-builder-row fusion-row fusion-flex-align-items-flex-start fusion-flex-content-wrap\" style=\"max-width:1372.8px;margin-left: calc(-4% \/ 2 );margin-right: calc(-4% \/ 2 );\"><div class=\"fusion-layout-column fusion_builder_column fusion-builder-column-5 fusion_builder_column_1_1 1_1 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:100%;--awb-margin-top-large:20px;--awb-spacing-right-large:1.92%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:1.92%;--awb-width-medium:100%;--awb-order-medium:0;--awb-spacing-right-medium:1.92%;--awb-spacing-left-medium:1.92%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;\"><div class=\"fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column\"><div class=\"fusion-title title fusion-title-37 fusion-sep-none fusion-title-text fusion-title-size-two\" style=\"--awb-text-color:var(--awb-color8);\"><h2 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:40;line-height:1.5;\">Business Logic Layer<\/h2><\/div><div class=\"fusion-title title fusion-title-38 fusion-sep-none fusion-title-text fusion-title-size-three\" style=\"--awb-text-color:var(--awb-color8);\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\">Create bloc files<\/h3><\/div><div class=\"fusion-text fusion-text-24\" style=\"--awb-font-size:var(--awb-typography4-font-size);--awb-line-height:var(--awb-typography4-line-height);--awb-letter-spacing:var(--awb-typography4-letter-spacing);--awb-text-transform:var(--awb-typography4-text-transform);--awb-text-font-family:var(--awb-typography4-font-family);--awb-text-font-weight:var(--awb-typography4-font-weight);--awb-text-font-style:var(--awb-typography4-font-style);\"><ul>\n<li>Install bloc plugin in your IDE<\/li>\n<li>Restart your IDE<\/li>\n<li>Go to File -&gt; New -&gt; Bloc Class<\/li>\n<li>Enter your bloc name that you want then you see in the lib directory the name bloc is created and it has three different file wather_bloc.dart, weather_event.dart and weather_state<\/li>\n<\/ul>\n<p><b>Bloc: <\/b>The weather_bloc.dart class is a bridge between our UI and the Data layer(weather_repository_impl.dart), In other words, this class will handle all the Events triggered by the User and send the relevant State back to the UI.<\/p>\n<p>We are extending our WeatherBloc class with Bloc which takes two things WeatherEvent and WeatherState. As the name suggests, they handle the applications State and Events respectively.<\/p>\n<p>These two classes are implemented in the weather_event.dart and weather_state.dart respectively.<\/p>\n<\/div><div class=\"fusion-title title fusion-title-39 fusion-sep-none fusion-title-text fusion-title-size-four\" style=\"--awb-text-color:var(--awb-color8);\"><h4 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:24;line-height:1.5;\">Weather_bloc.dart<\/h4><\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-19 > .CodeMirror, .fusion-syntax-highlighter-19 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-19 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-19 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-19 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_19\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_19\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_19\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">enum WeatherCondition {\n clear,\n rainy,\n cloudy,\n snowy,\n unknown,\n}\n\nenum TemperatureUnits { fahrenheit, celsius }\n\nextension TemperatureUnitsX on TemperatureUnits {\n bool get isFahrenheit => this == TemperatureUnits.fahrenheit;\n\n bool get isCelsius => this == TemperatureUnits.celsius;\n}\n\nclass Weather extends Equatable {\n final String location;\n final double temperature;\n final WeatherCondition condition;\n\n const Weather({\n   required this.location,\n   required this.temperature,\n   required this.condition,\n });\n\n @override\n List<Object?> get props => [location, temperature, condition];\n}<\/textarea><\/div><div class=\"fusion-text fusion-text-25\"><p>&nbsp;<\/p>\n<p>_getWeather(String? city) uses our weather repository to try and retrieve a weather object for the given city<\/p>\n<\/div><div class=\"fusion-title title fusion-title-40 fusion-sep-none fusion-title-text fusion-title-size-four\" style=\"--awb-text-color:var(--awb-color8);\"><h4 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:24;line-height:1.5;\">Event: weatherEvent.dart<\/h4><\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-20 > .CodeMirror, .fusion-syntax-highlighter-20 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-20 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-20 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-20 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_20\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_20\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_20\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">abstract class WeatherEvent extends Equatable {\n const WeatherEvent();\n}\n\nclass GetWeather extends WeatherEvent {\n final String city;\n\n const GetWeather({required this.city});\n\n @override\n List<Object?> get props => [];\n}<\/textarea><\/div><div class=\"fusion-text fusion-text-26\"><p>&nbsp;<\/p>\n<ul>\n<li>In this class, we define different kinds of events by extending the abstract event class.<\/li>\n<li>For example, when the user presses the search icon, the WeatherRequest event is triggered.<\/li>\n<li>Here I&#8217;ve also created a final field called city. It&#8217;s nothing but a string inputted by the user in the search text field.<\/li>\n<li>We have to pass it to the event in order to access it in our bloc.<\/li>\n<li>Now let&#8217;s implement weather_state.dart class<\/li>\n<\/ul>\n<\/div><div class=\"fusion-title title fusion-title-41 fusion-sep-none fusion-title-text fusion-title-size-four\" style=\"--awb-text-color:var(--awb-color8);\"><h4 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:24;line-height:1.5;\"><div><\/div>\n<p>State:<br \/>\nWeather_state.dart<\/p>\n<p>&nbsp;<\/p><\/h4><\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-21 > .CodeMirror, .fusion-syntax-highlighter-21 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-21 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-21 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-21 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_21\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_21\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_21\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">enum Status { loading, success, failed, initial }\n\nclass WeatherState extends Equatable {\n final Status status;\n final Weather? weather;\n final TemperatureUnits temperatureUnits;\n\n const WeatherState(\n     {this.status = Status.initial,\n     this.weather,\n     this.temperatureUnits = TemperatureUnits.celsius});\n\n WeatherState copyWith(\n     {Status? status, Weather? weather, TemperatureUnits? temperatureUnits}) {\n   return WeatherState(\n       status: status ?? this.status,\n       weather: weather ?? this.weather,\n       temperatureUnits: temperatureUnits ?? this.temperatureUnits);\n }\n\n @override\n List<Object?> get props => [status, weather, temperatureUnits];\n}<\/textarea><\/div><div class=\"fusion-text fusion-text-27\"><p>&nbsp;<\/p>\n<p>In this class, we define only one state but if you want then you create a abstract class like this abstract class WeatherState {} and extend this class like<\/p>\n<p>class WeatherInitial extends WeatherState {}<\/p>\n<p>class WeatherLoadInprogress extends WeatherState {}<\/p>\n<p><b>There are four states our weather app can be in:<\/b><\/p>\n<ul>\n<li>Initial before anything loads<\/li>\n<li>Loading during the API call<\/li>\n<li>Success if the API call is successful<\/li>\n<li>Failure if the API call is unsuccessful<\/li>\n<\/ul>\n<p>The WeatherStatus enum will represent the above.<\/p>\n<\/div><\/div><\/div><\/div><\/div><div class=\"fusion-fullwidth fullwidth-box fusion-builder-row-5 fusion-flex-container nonhundred-percent-fullwidth non-hundred-percent-height-scrolling\" style=\"--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-flex-wrap:wrap;\" ><div class=\"fusion-builder-row fusion-row fusion-flex-align-items-flex-start fusion-flex-content-wrap\" style=\"max-width:1372.8px;margin-left: calc(-4% \/ 2 );margin-right: calc(-4% \/ 2 );\"><div class=\"fusion-layout-column fusion_builder_column fusion-builder-column-6 fusion_builder_column_1_1 1_1 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:100%;--awb-margin-top-large:20px;--awb-spacing-right-large:1.92%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:1.92%;--awb-width-medium:100%;--awb-order-medium:0;--awb-spacing-right-medium:1.92%;--awb-spacing-left-medium:1.92%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;\"><div class=\"fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column\"><div class=\"fusion-title title fusion-title-42 fusion-sep-none fusion-title-text fusion-title-size-two\" style=\"--awb-text-color:var(--awb-color8);\"><h2 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:40;line-height:1.5;\">How To Access bloc?<\/h2><\/div><div class=\"fusion-text fusion-text-28\" style=\"--awb-font-size:var(--awb-typography4-font-size);--awb-line-height:var(--awb-typography4-line-height);--awb-letter-spacing:var(--awb-typography4-letter-spacing);--awb-text-transform:var(--awb-typography4-text-transform);--awb-text-font-family:var(--awb-typography4-font-family);--awb-text-font-weight:var(--awb-typography4-font-weight);--awb-text-font-style:var(--awb-typography4-font-style);\"><p><b>Trigger an Event:<\/b><\/p>\n<p>You need a context bloc and event that you trigger. In this WeatherBloc is our bloc and GetWeather is our event for getting weather and it needs a field city. We input the city dhaka.<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-22 > .CodeMirror, .fusion-syntax-highlighter-22 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-22 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-22 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-22 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_22\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_22\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_22\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">context.read<WeatherBloc>().add(GetWeather(City:\"texas\"));<\/textarea><\/div><div class=\"fusion-title title fusion-title-43 fusion-sep-none fusion-title-text fusion-title-size-three\" style=\"--awb-text-color:var(--awb-color8);\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\"><div><\/div>\n<p>BlocProvider<\/h3><\/div><div class=\"fusion-text fusion-text-29\"><ul>\n<li>BlocProvider widget provides a bloc to its children (i.e Widgets).<\/li>\n<li>BlocProvider is used as a dependency injection (DI) widget so that a single instance of a bloc can be provided to multiple widgets within a subtree.<\/li>\n<li>Okay. So now we know what BlocProvider does, where can we put it?<\/li>\n<li>You put the BlocProvider the root MaterialApp or Every single Widget. Here we provide blocProvider in every widget<\/li>\n<\/ul>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-23 > .CodeMirror, .fusion-syntax-highlighter-23 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-23 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-23 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-23 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_23\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_23\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_23\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">Widget build(BuildContext context) {\n return BlocProvider(\n   create: (context) => WeatherBloc(context.read<WeatherRepositoryImpl>()),\n   child: const WeatherView(),\n );\n}<\/textarea><\/div><div class=\"fusion-text fusion-text-30\"><ul>\n<li>Now you can access the WeatherBloc<\/li>\n<\/ul>\n<\/div><div class=\"fusion-title title fusion-title-44 fusion-sep-none fusion-title-text fusion-title-size-three\" style=\"--awb-text-color:var(--awb-color8);\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\">MultiBlocProvider<\/h3><\/div><div class=\"fusion-text fusion-text-31\"><ul>\n<li>Bloc provides us with a MultiBlocProvider widget that takes a List of Bloc and provides it to its children. Let me demonstrate.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-24 > .CodeMirror, .fusion-syntax-highlighter-24 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-24 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-24 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-24 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_24\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_24\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_24\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">MultiBlocProvider(\n  providers: [\n    BlocProvider<BlocA>(\n      create: (BuildContext context) => BlocA(),\n    ),\n    BlocProvider<BlocB>(\n      create: (BuildContext context) => BlocB(),\n    ),\n    BlocProvider<BlocC>(\n      create: (BuildContext context) => BlocC(),\n    ),\n  ],\n  child: ChildA(),\n)<\/textarea><\/div><div class=\"fusion-title title fusion-title-45 fusion-sep-none fusion-title-text fusion-title-size-three\" style=\"--awb-text-color:var(--awb-color8);\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\"><div><\/div>\n<p>BlocBuilder<\/h3><\/div><div class=\"fusion-text fusion-text-32\"><ul>\n<li>BlocBuilder is a widget that helps Re-building the UI based on State changes.<\/li>\n<li>In our case we want our UI to update the state when the user presses the Get Weather button.<\/li>\n<li>BlocBuilder builds the UI every single time state changes<\/li>\n<li>So, it&#8217;s very necessary to place BlocBuilder around the Widget that we want to rebuild.<\/li>\n<li>You can also wrap the whole Widget inside the BlocBuilder (i.e around the Scaffold), but it&#8217;s not a good way. Because think about the time and processing power that will be consumed when your whole widget tree rebuilds just to update a Text widget inside the tree. So make sure you wrap the BlocBuilder around the widget that needs to be rebuild when the state changes.<\/li>\n<\/ul>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-25 > .CodeMirror, .fusion-syntax-highlighter-25 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-25 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-25 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-25 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_25\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_25\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_25\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">BlocBuilder<BlocA, BlocAState>(\n  builder: (context, state) {\n    \/\/ return widget here based on BlocA's state\n  }\n)<\/textarea><\/div><div class=\"fusion-text fusion-text-33\"><p>&nbsp;<\/p>\n<ul>\n<li>Only specify the bloc if you wish to provide a bloc that will be scoped to a single widget and isn&#8217;t accessible via a parent BlocProvider and the current BuildContext.<\/li>\n<li>Build When parameter takes the previous bloc state and current bloc state and returns a boolean. If buildWhen returns true, builder will be called with state and the widget will rebuild. If buildWhen returns false, builder will not be called with state and no rebuild will occur. Actually it prevent unexpected build.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-26 > .CodeMirror, .fusion-syntax-highlighter-26 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-26 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-26 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-26 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_26\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_26\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_26\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">BlocBuilder<BlocA, BlocAState>(\n  buildWhen: (previousState, state) {\n    \/\/ return true\/false to determine whether or not\n    \/\/ to rebuild the widget with state\n  },\n  builder: (context, state) {\n    \/\/ return widget here based on BlocA's state\n  }\n)<\/textarea><\/div><div class=\"fusion-title title fusion-title-46 fusion-sep-none fusion-title-text fusion-title-size-three\" style=\"--awb-text-color:var(--awb-color8);\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\"><div><\/div>\n<p>BlocSelector<\/h3><\/div><div class=\"fusion-text fusion-text-34\"><ul>\n<li>Unnecessary builds are prevented if the selected value does not change.<\/li>\n<li>The selected value must be immutable in order for BlocSelector to accurately determine whether builder should be called again.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-27 > .CodeMirror, .fusion-syntax-highlighter-27 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-27 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-27 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-27 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_27\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_27\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_27\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">BlocSelector<BlocA, BlocAState, SelectedState>( selector: (state) { \/\/ return selected state based on the provided state. }, builder: (context, state) { \/\/ return widget here based on the selected state. }, )<\/textarea><\/div><div class=\"fusion-title title fusion-title-47 fusion-sep-none fusion-title-text fusion-title-size-three\" style=\"--awb-text-color:var(--awb-color8);\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\"><div><\/div>\n<p>BlocListner<\/h3><\/div><div class=\"fusion-text fusion-text-35\"><ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">As the name suggests, this will listen to any state change as BlocBuilder does.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">But instead of building the widget like BlocBuilder, it takes one function, listener, which is called only once per state, not including the initial state.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">It also has a bloc parameter. Only specify the bloc if you wish to provide a bloc that is otherwise not accessible via BlocProvider and the current BuildContext.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The listenWhen parameter is the same as BlocBuilder&#8217;s buildWhen but for Listener.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The whole idea of BlocListener is &#8211; It is not responsible for building\/updating the widget like BlocBuilder does.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">It only listens to the state changes and performs some operation. The operation could be (Navigating to other screens when state changes, Showing Snackbar on a particular state, etc).<\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-28 > .CodeMirror, .fusion-syntax-highlighter-28 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-28 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-28 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-28 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_28\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_28\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_28\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">BlocListener<BlocA, BlocAState>(\n  listenWhen: (previousState, state) {\n    \/\/ return true\/false to determine whether or not\n    \/\/ to call listener with state\n  },\n  listener: (context, state) {\n    \/\/ do stuff here based on BlocA's state\n  },\n  child: Container(),\n)<\/textarea><\/div><div class=\"fusion-title title fusion-title-48 fusion-sep-none fusion-title-text fusion-title-size-three\" style=\"--awb-text-color:var(--awb-color8);\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\"><div><\/div>\n<p>MultiBlocListener<\/h3><\/div><div class=\"fusion-text fusion-text-36\"><ul>\n<li style=\"font-weight: 400;\">MultiBlocListener is a Flutter widget that merges multiple BlocListener widgets into one. MultiBlocListener improves the readability and eliminates the need to nest multiple BlocListeners<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-29 > .CodeMirror, .fusion-syntax-highlighter-29 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-29 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-29 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-29 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_29\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_29\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_29\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">MultiBlocListener(\n  listeners: [\n    BlocListener<BlocA, BlocAState>(\n      listener: (context, state) {},\n    ),\n    BlocListener<BlocB, BlocBState>(\n      listener: (context, state) {},\n    ),\n    BlocListener<BlocC, BlocCState>(\n      listener: (context, state) {},\n    ),\n  ],\n  child: ChildA(),\n)<\/textarea><\/div><div class=\"fusion-title title fusion-title-49 fusion-sep-none fusion-title-text fusion-title-size-three\" style=\"--awb-text-color:var(--awb-color8);\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\"><div><\/div>\n<p>BlocConsumer:<\/h3><\/div><div class=\"fusion-text fusion-text-37\"><ul>\n<li style=\"font-weight: 400;\">Bloc provides a BlocConsumer widget, which combines both BlocListener and BlocBuilder.<\/li>\n<li style=\"font-weight: 400;\"><span style=\"color: var(--body_typography-color); font-family: var(--body_typography-font-family); font-size: var(--body_typography-font-size); letter-spacing: var(--body_typography-letter-spacing);\">An optional listenWhen and buildWhen can be implemented for more granular control over when the listener and builder are called.<\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-30 > .CodeMirror, .fusion-syntax-highlighter-30 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-30 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-30 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-30 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_30\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_30\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_30\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">BlocConsumer<BlocA, BlocAState>(\n  listenWhen: (previous, current) {\n    \/\/ return true\/false to determine whether or not\n    \/\/ to invoke listener with state\n  },\n  listener: (context, state) {\n    \/\/ do stuff here based on BlocA's state\n  },\n  buildWhen: (previous, current) {\n    \/\/ return true\/false to determine whether or not\n    \/\/ to rebuild the widget with state\n  },\n  builder: (context, state) {\n    \/\/ return widget here based on BlocA's state\n  }\n)<\/textarea><\/div><div class=\"fusion-title title fusion-title-50 fusion-sep-none fusion-title-text fusion-title-size-three\" style=\"--awb-text-color:var(--awb-color8);\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\"><div><\/div>\n<p>RepositoryProvider:<\/h3><\/div><div class=\"fusion-text fusion-text-38\"><ul>\n<li>It is the same widget as BlocProvider.<\/li>\n<li>But the main difference is BlocProvider provides a single instance of bloc to its children whereas RepositoryProvider provides repositories to its children.<\/li>\n<li>It is used as a dependency injection (DI) widget so that a single instance of a repository can be provided to multiple widgets within a subtree.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-31 > .CodeMirror, .fusion-syntax-highlighter-31 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-31 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-31 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-31 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_31\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_31\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_31\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">RepositoryProvider(\n  create: (context) => RepositoryA(),\n  child: ChildA(),\n);<\/textarea><\/div><div class=\"fusion-text fusion-text-39\"><p>&nbsp;<\/p>\n<ul>\n<li>Retrieve the Repository<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-32 > .CodeMirror, .fusion-syntax-highlighter-32 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-32 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-32 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-32 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_32\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_32\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_32\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">\/\/ with extensions\ncontext.read<RepositoryA>();\nRepositoryProvider.of<RepositoryA>(context)<\/textarea><\/div><div class=\"fusion-title title fusion-title-51 fusion-sep-none fusion-title-text fusion-title-size-three\" style=\"--awb-text-color:var(--awb-color8);\"><h3 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:32;line-height:1.5;\"><div><\/div>\n<p>MultiRepositoryProvider:<\/h3><\/div><div class=\"fusion-text fusion-text-40\"><ul>\n<li><span style=\"font-weight: 400;\">MultiRepositoryProvider is a Flutter widget that merges multiple RepositoryProvider widgets into one. MultiRepositoryProvider improves the readability and eliminates the need to nest multiple RepositoryProvider. By using MultiRepositoryProvider we can go from:<\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-33 > .CodeMirror, .fusion-syntax-highlighter-33 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color8);}.fusion-syntax-highlighter-33 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color8); }.fusion-syntax-highlighter-33 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color4); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-33 fusion-syntax-highlighter-theme-dark\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_33\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_33\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_33\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"oceanic-next\">MultiRepositoryProvider(\n  providers: [\n    RepositoryProvider<RepositoryA>(\n      create: (context) => RepositoryA(),\n    ),\n    RepositoryProvider<RepositoryB>(\n      create: (context) => RepositoryB(),\n    ),\n    RepositoryProvider<RepositoryC>(\n      create: (context) => RepositoryC(),\n    ),\n  ],\n  child: ChildA(),\n)<\/textarea><\/div><\/div><\/div><\/div><\/div><div class=\"fusion-fullwidth fullwidth-box fusion-builder-row-6 fusion-flex-container nonhundred-percent-fullwidth non-hundred-percent-height-scrolling\" style=\"--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-flex-wrap:wrap;\" ><div class=\"fusion-builder-row fusion-row fusion-flex-align-items-flex-start fusion-flex-content-wrap\" style=\"max-width:1372.8px;margin-left: calc(-4% \/ 2 );margin-right: calc(-4% \/ 2 );\"><div class=\"fusion-layout-column fusion_builder_column fusion-builder-column-7 fusion_builder_column_1_5 1_5 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:20%;--awb-margin-top-large:20px;--awb-spacing-right-large:9.6%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:9.6%;--awb-width-medium:20%;--awb-order-medium:0;--awb-spacing-right-medium:9.6%;--awb-spacing-left-medium:9.6%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;\"><div class=\"fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column\"><div class=\"fusion-image-element \" style=\"--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);\"><span class=\" fusion-imageframe imageframe-none imageframe-5 hover-type-none\" style=\"border-radius:8px;\"><img decoding=\"async\" width=\"46\" height=\"46\" title=\"Vector\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%2746%27%20height%3D%2746%27%20viewBox%3D%270%200%2046%2046%27%3E%3Crect%20width%3D%2746%27%20height%3D%2746%27%20fill-opacity%3D%220%22%2F%3E%3C%2Fsvg%3E\" data-orig-src=\"https:\/\/jp.polygontech.xyz\/wp-content\/uploads\/2023\/06\/Vector.png\" alt class=\"lazyload img-responsive wp-image-8111\"\/><\/span><\/div><div class=\"fusion-builder-row fusion-builder-row-inner fusion-row fusion-flex-align-items-flex-start fusion-flex-content-wrap\" style=\"width:104% !important;max-width:104% !important;margin-left: calc(-4% \/ 2 );margin-right: calc(-4% \/ 2 );\"><div class=\"fusion-layout-column fusion_builder_column_inner fusion-builder-nested-column-4 fusion_builder_column_inner_1_5 1_5 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:20%;--awb-margin-top-large:20px;--awb-spacing-right-large:9.6%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:9.6%;--awb-width-medium:20%;--awb-order-medium:0;--awb-spacing-right-medium:9.6%;--awb-spacing-left-medium:9.6%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;\"><div class=\"fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column\"><\/div><\/div><\/div><div ><a class=\"fusion-button button-flat fusion-button-default-size button-custom fusion-button-default button-1 fusion-button-default-span fusion-button-default-type\" style=\"--button_accent_color:var(--awb-color1);--button_border_color:#2cbc63;--button_accent_hover_color:var(--awb-color1);--button_border_hover_color:#15d16c;--button_border_width-top:1px;--button_border_width-right:1px;--button_border_width-bottom:1px;--button_border_width-left:1px;--button_gradient_top_color:var(--awb-color4);--button_gradient_bottom_color:var(--awb-color4);--button_gradient_top_color_hover:hsla(var(--awb-color4-h),var(--awb-color4-s),calc(var(--awb-color4-l) - 8%),var(--awb-color4-a));--button_gradient_bottom_color_hover:hsla(var(--awb-color4-h),var(--awb-color4-s),calc(var(--awb-color4-l) - 8%),var(--awb-color4-a));\" target=\"_self\" href=\"https:\/\/github.com\/PolygonTechnology-xyz\/flutter_weather.git\"><span class=\"fusion-button-text\"><b>Git Repository<\/b><\/span><\/a><\/div><\/div><\/div><\/div><\/div><div class=\"fusion-fullwidth fullwidth-box fusion-builder-row-7 fusion-flex-container nonhundred-percent-fullwidth non-hundred-percent-height-scrolling\" style=\"--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-flex-wrap:wrap;\" ><div class=\"fusion-builder-row fusion-row fusion-flex-align-items-flex-start fusion-flex-content-wrap\" style=\"max-width:1372.8px;margin-left: calc(-4% \/ 2 );margin-right: calc(-4% \/ 2 );\"><div class=\"fusion-layout-column fusion_builder_column fusion-builder-column-8 fusion_builder_column_1_1 1_1 fusion-flex-column fusion-flex-align-self-center\" style=\"--awb-padding-top:32px;--awb-padding-right:48px;--awb-padding-bottom:32px;--awb-padding-left:48px;--awb-overflow:hidden;--awb-bg-color:rgba(59,199,123,0.2);--awb-bg-color-hover:rgba(59,199,123,0.2);--awb-bg-size:cover;--awb-border-color:rgba(119,119,119,0.5);--awb-border-style:solid;--awb-border-radius:16px 16px 16px 16px;--awb-width-large:100%;--awb-margin-top-large:20px;--awb-spacing-right-large:1.92%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:1.92%;--awb-width-medium:100%;--awb-order-medium:0;--awb-spacing-right-medium:1.92%;--awb-spacing-left-medium:1.92%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;\"><div class=\"fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-row fusion-flex-align-items-center\"><div class=\"fusion-title title fusion-title-52 fusion-sep-none fusion-title-text fusion-title-size-four\" style=\"--awb-text-color:var(--awb-color8);\"><h4 class=\"fusion-title-heading title-heading-left fusion-responsive-typography-calculated\" style=\"margin:0;--fontSize:24;line-height:1.5;\"><span style=\"font-weight: 400;\">Wrapping Up<\/span><\/h4><\/div><div class=\"fusion-text fusion-text-41 fusion-text-no-margin\" style=\"--awb-font-size:var(--awb-typography4-font-size);--awb-line-height:var(--awb-typography4-line-height);--awb-letter-spacing:var(--awb-typography4-letter-spacing);--awb-text-transform:var(--awb-typography4-text-transform);--awb-text-color:var(--awb-custom10);--awb-text-font-family:var(--awb-typography4-font-family);--awb-text-font-weight:var(--awb-typography4-font-weight);--awb-text-font-style:var(--awb-typography4-font-style);\"><p>Bloc patterns can be challenging to understand at first, but it will become easier with practice. The best way to learn is by building small applications. I hope this article has helped you to understand the basics of Bloc. If you have any questions or feedback, please leave a comment below.<\/p>\n<p>Here are some additional tips for learning Bloc:<\/p>\n<ul>\n<li>Start with a simple application.<\/li>\n<li>Break the application down into small, manageable pieces.<\/li>\n<li>Use the Bloc library documentation to help you get started.<\/li>\n<li>Don&#8217;t be afraid to ask for help. There are many resources available online and in the Flutter community.<\/li>\n<\/ul>\n<p>With a little practice, you&#8217;ll be using Bloc like a pro in no time!<\/p>\n<\/div><\/div><\/div><\/div><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Discover the power of Flutter Bloc architecture. Learn about its core concepts, benefits, and architecture components. Build scalable and maintainable Flutter apps with ease.<\/p>\n","protected":false},"author":4,"featured_media":8077,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1088],"tags":[1090,1089,1091],"class_list":["post-8087","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology","tag-bloc","tag-flutter","tag-flutter-bloc"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Exploring Flutter Bloc: Concepts, Benefits, and Architecture<\/title>\n<meta name=\"description\" content=\"Flutter Bloc is a state management solution for Flutter apps. Learn how to use Flutter Bloc to manage the state of your Flutter apps.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Exploring Flutter Bloc: Concepts, Benefits, and Architecture\" \/>\n<meta property=\"og:description\" content=\"Flutter Bloc is a state management solution for Flutter apps. Learn how to use Flutter Bloc to manage the state of your Flutter apps.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/\" \/>\n<meta property=\"og:site_name\" content=\"PolygonTech\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-06T06:54:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-11T08:26:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jp.polygontech.xyz\/wp-content\/uploads\/2023\/06\/Flutter-Bloc-Concepts-Benefits-Architecture.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Pritimoy Biswas\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pritimoy Biswas\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"24 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/\"},\"author\":{\"name\":\"Pritimoy Biswas\",\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/#\/schema\/person\/a96066fad5b1a9b51aec4e1a68532547\"},\"headline\":\"Exploring Flutter Bloc: Concepts, Benefits, and Architecture\",\"datePublished\":\"2023-06-06T06:54:10+00:00\",\"dateModified\":\"2023-06-11T08:26:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/\"},\"wordCount\":14495,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/#organization\"},\"keywords\":[\"Bloc\",\"Flutter\",\"Flutter Bloc\"],\"articleSection\":[\"Technology\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/\",\"url\":\"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/\",\"name\":\"Exploring Flutter Bloc: Concepts, Benefits, and Architecture\",\"isPartOf\":{\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/#website\"},\"datePublished\":\"2023-06-06T06:54:10+00:00\",\"dateModified\":\"2023-06-11T08:26:33+00:00\",\"description\":\"Flutter Bloc is a state management solution for Flutter apps. Learn how to use Flutter Bloc to manage the state of your Flutter apps.\",\"breadcrumb\":{\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jp.polygontech.xyz\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Exploring Flutter Bloc: Concepts, Benefits, and Architecture\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/#website\",\"url\":\"https:\/\/jp.polygontech.xyz\/en\/\",\"name\":\"PolygonTech\",\"description\":\"Unlock Your Digital Growth Potential\",\"publisher\":{\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jp.polygontech.xyz\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/#organization\",\"name\":\"Polygontech\",\"url\":\"https:\/\/jp.polygontech.xyz\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jp.polygontech.xyz\/wp-content\/uploads\/2022\/07\/menu-logo.svg\",\"contentUrl\":\"https:\/\/jp.polygontech.xyz\/wp-content\/uploads\/2022\/07\/menu-logo.svg\",\"width\":233,\"height\":54,\"caption\":\"Polygontech\"},\"image\":{\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/#\/schema\/person\/a96066fad5b1a9b51aec4e1a68532547\",\"name\":\"Pritimoy Biswas\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jp.polygontech.xyz\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d4ec74b8d79efa133ce0802daefadd48f54b3eba484d658f9732d2f16f7b74a0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d4ec74b8d79efa133ce0802daefadd48f54b3eba484d658f9732d2f16f7b74a0?s=96&d=mm&r=g\",\"caption\":\"Pritimoy Biswas\"},\"url\":\"https:\/\/jp.polygontech.xyz\/en\/author\/pritimoy\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Exploring Flutter Bloc: Concepts, Benefits, and Architecture","description":"Flutter Bloc is a state management solution for Flutter apps. Learn how to use Flutter Bloc to manage the state of your Flutter apps.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/","og_locale":"en_US","og_type":"article","og_title":"Exploring Flutter Bloc: Concepts, Benefits, and Architecture","og_description":"Flutter Bloc is a state management solution for Flutter apps. Learn how to use Flutter Bloc to manage the state of your Flutter apps.","og_url":"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/","og_site_name":"PolygonTech","article_published_time":"2023-06-06T06:54:10+00:00","article_modified_time":"2023-06-11T08:26:33+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/jp.polygontech.xyz\/wp-content\/uploads\/2023\/06\/Flutter-Bloc-Concepts-Benefits-Architecture.png","type":"image\/png"}],"author":"Pritimoy Biswas","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Pritimoy Biswas","Est. reading time":"24 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/#article","isPartOf":{"@id":"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/"},"author":{"name":"Pritimoy Biswas","@id":"https:\/\/jp.polygontech.xyz\/en\/#\/schema\/person\/a96066fad5b1a9b51aec4e1a68532547"},"headline":"Exploring Flutter Bloc: Concepts, Benefits, and Architecture","datePublished":"2023-06-06T06:54:10+00:00","dateModified":"2023-06-11T08:26:33+00:00","mainEntityOfPage":{"@id":"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/"},"wordCount":14495,"commentCount":0,"publisher":{"@id":"https:\/\/jp.polygontech.xyz\/en\/#organization"},"keywords":["Bloc","Flutter","Flutter Bloc"],"articleSection":["Technology"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/","url":"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/","name":"Exploring Flutter Bloc: Concepts, Benefits, and Architecture","isPartOf":{"@id":"https:\/\/jp.polygontech.xyz\/en\/#website"},"datePublished":"2023-06-06T06:54:10+00:00","dateModified":"2023-06-11T08:26:33+00:00","description":"Flutter Bloc is a state management solution for Flutter apps. Learn how to use Flutter Bloc to manage the state of your Flutter apps.","breadcrumb":{"@id":"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jp.polygontech.xyz\/en\/flutter-bloc-concepts-benefits-architecture\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jp.polygontech.xyz\/en\/"},{"@type":"ListItem","position":2,"name":"Exploring Flutter Bloc: Concepts, Benefits, and Architecture"}]},{"@type":"WebSite","@id":"https:\/\/jp.polygontech.xyz\/en\/#website","url":"https:\/\/jp.polygontech.xyz\/en\/","name":"PolygonTech","description":"Unlock Your Digital Growth Potential","publisher":{"@id":"https:\/\/jp.polygontech.xyz\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jp.polygontech.xyz\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jp.polygontech.xyz\/en\/#organization","name":"Polygontech","url":"https:\/\/jp.polygontech.xyz\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jp.polygontech.xyz\/en\/#\/schema\/logo\/image\/","url":"https:\/\/jp.polygontech.xyz\/wp-content\/uploads\/2022\/07\/menu-logo.svg","contentUrl":"https:\/\/jp.polygontech.xyz\/wp-content\/uploads\/2022\/07\/menu-logo.svg","width":233,"height":54,"caption":"Polygontech"},"image":{"@id":"https:\/\/jp.polygontech.xyz\/en\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jp.polygontech.xyz\/en\/#\/schema\/person\/a96066fad5b1a9b51aec4e1a68532547","name":"Pritimoy Biswas","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jp.polygontech.xyz\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d4ec74b8d79efa133ce0802daefadd48f54b3eba484d658f9732d2f16f7b74a0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d4ec74b8d79efa133ce0802daefadd48f54b3eba484d658f9732d2f16f7b74a0?s=96&d=mm&r=g","caption":"Pritimoy Biswas"},"url":"https:\/\/jp.polygontech.xyz\/en\/author\/pritimoy\/"}]}},"_links":{"self":[{"href":"https:\/\/jp.polygontech.xyz\/en\/wp-json\/wp\/v2\/posts\/8087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jp.polygontech.xyz\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jp.polygontech.xyz\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jp.polygontech.xyz\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/jp.polygontech.xyz\/en\/wp-json\/wp\/v2\/comments?post=8087"}],"version-history":[{"count":13,"href":"https:\/\/jp.polygontech.xyz\/en\/wp-json\/wp\/v2\/posts\/8087\/revisions"}],"predecessor-version":[{"id":8115,"href":"https:\/\/jp.polygontech.xyz\/en\/wp-json\/wp\/v2\/posts\/8087\/revisions\/8115"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jp.polygontech.xyz\/en\/wp-json\/wp\/v2\/media\/8077"}],"wp:attachment":[{"href":"https:\/\/jp.polygontech.xyz\/en\/wp-json\/wp\/v2\/media?parent=8087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jp.polygontech.xyz\/en\/wp-json\/wp\/v2\/categories?post=8087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jp.polygontech.xyz\/en\/wp-json\/wp\/v2\/tags?post=8087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}