<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nirav Kakadiya on Medium]]></title>
        <description><![CDATA[Stories by Nirav Kakadiya on Medium]]></description>
        <link>https://medium.com/@kakadiyanirav25?source=rss-a9e76cdb22c7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ad_KgCY0LZNFGrs26KygOw.png</url>
            <title>Stories by Nirav Kakadiya on Medium</title>
            <link>https://medium.com/@kakadiyanirav25?source=rss-a9e76cdb22c7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 08:53:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kakadiyanirav25/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Flexible vs Expanded in Flutter: A Complete Guide With Real Examples]]></title>
            <link>https://medium.com/@kakadiyanirav25/flexible-vs-expanded-in-flutter-a-complete-guide-with-real-examples-fe16015c3ca0?source=rss-a9e76cdb22c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe16015c3ca0</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Nirav Kakadiya]]></dc:creator>
            <pubDate>Wed, 07 Jan 2026 05:06:24 GMT</pubDate>
            <atom:updated>2026-01-07T05:06:24.819Z</atom:updated>
            <content:encoded><![CDATA[<p>Understand how Flutter layouts really work — and avoid overflow errors by choosing the right widget.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ulBzlRgfAPTaKQnvXyymAw.png" /></figure><p>If you’ve been building layouts using <strong>Flutter</strong>, you’ve almost certainly asked this question:</p><blockquote><strong><em>Should I use </em></strong><strong><em>Flexible or </em></strong><strong><em>Expanded?</em></strong></blockquote><p>They look similar, behave similarly, and yet using the wrong one often results in:</p><ul><li>Render overflow errors</li><li>Unexpected spacing</li><li>Broken UI on small screens</li></ul><p>This article explains the <strong>real difference</strong> between them with <strong>clear mental models and practical examples</strong>.</p><h3>What Problem Do Flexible and Expanded Solve?</h3><p>Both Flexible and Expanded are used <strong>inside Flex widgets</strong>, such as:</p><ul><li>Row</li><li>Column</li><li>Flex</li></ul><p>They control <strong>how available space is distributed</strong> among children <strong>along the main axis</strong>.</p><p>Without them, Flutter doesn’t know:</p><ul><li>Which widget should grow</li><li>Which widget should shrink</li><li>How to avoid overflow</li></ul><h3>Expanded: Takes All Available Space</h3><p>Expanded forces its child to <strong>occupy all remaining space</strong>.</p><h3>Example</h3><pre>Row(<br>  children: [<br>    Container(width: 80, color: Colors.red),<br>    Expanded(<br>      child: Container(color: Colors.blue),<br>    ),<br>  ],<br>)</pre><h3>What Happens?</h3><ul><li>Red container takes <strong>80 pixels</strong></li><li>Blue container fills <strong>all remaining width</strong></li></ul><p>➡ Expanded <strong>forces expansion</strong>, even if the child doesn’t need it.</p><h3>When to Use Expanded</h3><ul><li>Full-width buttons</li><li>Equal-width layouts (50/50)</li><li>Dashboards and grids</li><li>When empty space should never exist</li></ul><h3>Flexible: Space With Freedom</h3><p>Flexible allows its child to <strong>take only the space it needs</strong>, within constraints.</p><h3>Example</h3><pre>Row(<br>  children: [<br>    Icon(Icons.person),<br>    SizedBox(width: 8),<br>    Flexible(<br>      child: Text(<br>        &quot;This text wraps naturally without forcing extra space&quot;,<br>      ),<br>    ),<br>  ],<br>)</pre><h3>What Happens?</h3><ul><li>Text uses <strong>minimum required space</strong></li><li>Content wraps naturally</li><li>Layout adapts to screen size</li></ul><p>➡ Flexible <strong>respects content size</strong>.</p><h3>When to Use Flexible</h3><ul><li>Dynamic text</li><li>Labels, chips, and tags</li><li>List items with long titles</li><li>Chat bubbles</li></ul><h3>The fit Property (Very Important)</h3><p>Flexible has a fit parameter that controls how strict it is.</p><pre>Flexible(<br>  fit: FlexFit.loose, // default<br>  child: ...<br>)</pre><h3>Fit Types Explained</h3><p>Fit TypeBehaviorFlexFit.looseChild can be smaller than available spaceFlexFit.tightChild must fill all available space</p><p>👉 <strong>Expanded is just Flexible with </strong><strong>FlexFit.tight.</strong></p><h3>Expanded Is Just a Shortcut</h3><p>Internally, Flutter treats:</p><pre>Expanded(child: widget)</pre><p>the same as:</p><pre>Flexible(<br>  fit: FlexFit.tight,<br>  child: widget,<br>)</pre><h3>Key Insight</h3><blockquote><strong><em>Expanded = Forced Flexible</em></strong></blockquote><h3>Common Mistakes Developers Make</h3><h3>❌ Using Expanded for Text</h3><pre>Expanded(<br>  child: Text(&quot;Very long dynamic text&quot;),<br>)</pre><p>This often causes:</p><ul><li>Awkward spacing</li><li>Unnatural stretching</li><li>Poor responsiveness</li></ul><h3>❌ Using Too Many Expanded Widgets</h3><pre>Row(<br>  children: [<br>    Expanded(child: A()),<br>    Expanded(child: B()),<br>    Expanded(child: C()),<br>  ],<br>)</pre><p>All widgets get <strong>equal space</strong>, which may not be what you want.</p><h3>Correct Usage Patterns</h3><h3>1️⃣ Equal Layout Distribution</h3><pre>Row(<br>  children: [<br>    Expanded(child: LeftPanel()),<br>    Expanded(child: RightPanel()),<br>  ],<br>)</pre><h3>2️⃣ Fixed + Adaptive Content</h3><pre>Row(<br>  children: [<br>    Container(width: 100),<br>    Flexible(child: Text(description)),<br>  ],<br>)</pre><h3>3️⃣ Icon + Text Row (Most Common)</h3><pre>Row(<br>  children: [<br>    Icon(Icons.email),<br>    SizedBox(width: 8),<br>    Flexible(child: Text(email)),<br>  ],<br>)</pre><h3>Real-World Usage Guide</h3><p>UI ScenarioRecommendedProfile row (avatar + name)FlexibleCard action buttonExpandedChat message bubbleFlexibleDashboard gridExpandedLong list titlesFlexible</p><h3>Easy Mental Model to Remember</h3><ul><li>🧱 <strong>Expanded</strong> → “Fill everything”</li><li>🧩 <strong>Flexible</strong> → “Fit naturally”</li></ul><p>If your widget <strong>must stretch</strong>, use <strong>Expanded</strong><br>If your widget <strong>should adapt</strong>, use <strong>Flexible</strong></p><h3>Final Thoughts</h3><p>Choosing between Flexible and Expanded isn’t about syntax—it’s about <strong>layout intention</strong>.</p><p>Once you understand:</p><ul><li>how space is calculated</li><li>how constraints flow</li><li>and when stretching is required</li></ul><p>Your Flutter UIs become <strong>cleaner, more responsive, and bug-free</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe16015c3ca0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Android 16 KB Page Size Issue: Complete Guide to Fix Google Play Rejection ]]></title>
            <link>https://medium.com/@kakadiyanirav25/flutter-android-16-kb-page-size-issue-complete-guide-to-fix-google-play-rejection-340332809ab2?source=rss-a9e76cdb22c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/340332809ab2</guid>
            <category><![CDATA[google-play]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Nirav Kakadiya]]></dc:creator>
            <pubDate>Sat, 03 Jan 2026 09:29:21 GMT</pubDate>
            <atom:updated>2026-01-03T09:29:21.953Z</atom:updated>
            <content:encoded><![CDATA[<h3>If you recently uploaded a <strong>Flutter Android App Bundle (AAB)</strong> to Google Play and faced a rejection mentioning <strong>“16 KB page size compatibility”</strong>, you’re not alone. Many Flutter developers are running into this issue after recent Google Play updates.</h3><p>This article explains:</p><ul><li>What the <strong>16 KB page size issue</strong> means</li><li>Why <strong>Google Play</strong> rejects your app</li><li>How to <strong>verify</strong> the issue</li><li>And how to <strong>fix it permanently in Flutter</strong></li></ul><h3>📌 What Is the 16 KB Page Size Issue?</h3><p>Modern Android devices are shifting to <strong>16 KB memory pages</strong>. To support this change, <strong>Google Play</strong> now enforces that <strong>native libraries (</strong><strong>.so files)</strong> inside your app must be aligned to <strong>16 KB boundaries (0x10000)</strong>.</p><p>If even <strong>one native library</strong> is misaligned, your production release is rejected.</p><h3>🔴 Google Play Console Rejection (Screenshot)</h3><p>👉 <strong>Add this screenshot right after this heading</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vGY5Jdp_rplzwgPR.png" /></figure><p>📷 <strong>Screenshot suggestion</strong></p><ul><li>Google Play Console → Release → Production</li><li>Error message mentioning <strong>16 KB page size</strong> or <strong>native library alignment</strong></li></ul><p><strong>Caption idea for Medium:</strong></p><blockquote><em>Google Play Console rejection showing 16 KB page size compatibility issue</em></blockquote><h3>🧠 Why Flutter Apps Are Affected</h3><p>Apps built with <strong>Flutter</strong> include native components:</p><ul><li>Flutter engine libraries</li><li>Plugins using C/C++</li><li>Third-party SDKs</li></ul><p>Some of these libraries may still be aligned to <strong>0x4000</strong>, which violates <strong>Google Play</strong> requirements for <strong>Android</strong> devices using 16 KB pages.</p><h3>🔍 How to Verify the Alignment Issue</h3><p>After building your AAB, extract and inspect native libraries.</p><pre>readelf -l libapp.so | grep LOAD</pre><h3>❌ Incorrect Alignment Output (Screenshot)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*c4kSFsvQD3NR_qTr.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k1BWBW3KL-8DFMHz" /></figure><p>📷 <strong>Screenshot suggestion</strong></p><ul><li>Terminal output showing:</li></ul><pre>LOAD ... Align 0x4000</pre><p><strong>Caption:</strong></p><blockquote><em>Native library aligned to 0x4000 — this causes Google Play rejection</em></blockquote><h3>✅ Correct Alignment Output (Screenshot)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L0IMbkQUKswjdBJP.PNG" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qTmEsMXh9ZcGMZlw" /></figure><p>📷 <strong>Screenshot suggestion</strong></p><ul><li>Terminal output showing:</li></ul><pre>LOAD ... Align 0x10000</pre><p><strong>Caption:</strong></p><blockquote><em>Correct 64 KB (0x10000) alignment required by Google Play</em></blockquote><h3>✅ How to Fix the 16 KB Issue in Flutter</h3><h3>1️⃣ Upgrade Flutter SDK</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n5LtpKfRo8FqVG0a.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/0*4NJ019kIO43Rblpg.png" /></figure><pre>flutter upgrade</pre><p>📷 <strong>Screenshot:</strong><br>Terminal showing Flutter upgrading to latest stable version</p><h3>2️⃣ Update Android Gradle Plugin</h3><p>In android/build.gradle:</p><pre>dependencies {<br>    classpath &#39;com.android.tools.build:gradle:8.1.0&#39;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sMYJquGOoOs9BB0a.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*nOKOSxkLfuC6aRdB" /></figure><p>📷 <strong>Screenshot:</strong><br>Code editor showing AGP 8.1+</p><h3>3️⃣ Use Latest NDK Version</h3><p>In android/app/build.gradle:</p><pre>android {<br>    ndkVersion &quot;26.1.10909125&quot;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y31GPViFx5Iybd7a.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*isIjikJ-cRopR9oh.png" /></figure><p>📷 <strong>Screenshot:</strong><br>NDK version set explicitly</p><h3>4️⃣ Fix Native Packaging</h3><pre>packagingOptions {<br>    jniLibs {<br>        useLegacyPackaging = false<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/0*dVHFBqbSk9GUz5Vg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/0*nmi14HdheLeWz_pG.png" /></figure><p>📷 <strong>Screenshot:</strong><br>Gradle config disabling legacy packaging</p><h3>5️⃣ Clean &amp; Rebuild App Bundle</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LtcL3ezrcwzH86hR.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IUYuIHeqgzy9dpa6.png" /></figure><pre>flutter clean<br>flutter pub get<br>flutter build appbundle</pre><p>📷 <strong>Screenshot:</strong><br>Successful build appbundle output</p><h3>⚠️ Common Mistakes Developers Make</h3><ul><li>❌ Open testing works → <strong>Production still rejected</strong></li><li>❌ Fixing only one .so file</li><li>❌ Ignoring third-party plugins</li><li>❌ Uploading old cached AAB</li></ul><p>✔ Every ABI and native library must be aligned to <strong>0x10000</strong></p><h3>🏁 Final Thoughts</h3><p>The Flutter <strong>16 KB page size issue</strong> is not a bug — it’s a <strong>tooling mismatch</strong>. Once your Flutter SDK, Gradle, and NDK are properly updated, Google Play approvals become smooth again.</p><p>This issue will become <strong>mandatory for all apps</strong>, so fixing it now future-proofs your Flutter project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=340332809ab2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Provider vs BLoC in Flutter: Which State Management Should You Choose?]]></title>
            <link>https://medium.com/@kakadiyanirav25/provider-vs-bloc-in-flutter-which-state-management-should-you-choose-6d3e1bf51bfb?source=rss-a9e76cdb22c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d3e1bf51bfb</guid>
            <category><![CDATA[provider-vs-bloc]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[bloc]]></category>
            <category><![CDATA[provider]]></category>
            <dc:creator><![CDATA[Nirav Kakadiya]]></dc:creator>
            <pubDate>Thu, 10 Jul 2025 04:30:29 GMT</pubDate>
            <atom:updated>2025-07-10T04:30:29.457Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DrAkh6-_nfHwkkeQUpkaig.png" /></figure><p><strong>🧾 Blog Content (Markdown/Medium-compatible):</strong></p><pre># Provider vs BLoC in Flutter: Which State Management Should You Choose?<br><br>When building scalable Flutter apps, choosing the right state management approach is crucial. Two popular options developers often debate between are **Provider** and **BLoC** (Business Logic Component). But which one fits your project best?<br><br>In this article, I’ll break down the key differences, use cases, pros, and cons of both.<br><br>---<br><br>## 🔍 What is Provider?<br><br>**Provider** is a wrapper around Flutter’s built-in `InheritedWidget`. It offers a simple and lightweight way to manage and share state across your app.<br><br>### ✅ When to use Provider:<br>- For **small to medium** apps<br>- When you want a **less verbose**, reactive approach<br>- If your app doesn’t require complex state streams<br><br>### 🟢 Pros:<br>- Easy to learn and implement<br>- Part of the official Flutter ecosystem<br>- Less boilerplate<br>- Great for basic state and dependency injection<br><br>### 🔴 Cons:<br>- Can become messy in larger apps<br>- Less separation of business logic<br>- Doesn’t scale well with async data flow complexities<br><br>---<br><br>## 🔁 What is BLoC?<br><br>**BLoC (Business Logic Component)** is a pattern based on reactive programming using **Streams**. It helps separate business logic from UI using **events** and **states**.<br><br>### ✅ When to use BLoC:<br>- For **large-scale** or enterprise-grade applications<br>- When your app has **complex interactions**, **asynchronous flows**, or multiple layers of state<br><br>### 🟢 Pros:<br>- Clear separation of concerns<br>- Highly testable and maintainable<br>- Scales well with app complexity<br><br>### 🔴 Cons:<br>- Steeper learning curve<br>- More boilerplate code<br>- Might feel verbose for simple apps<br><br>---<br><br>## ⚖️ Provider vs BLoC: Head-to-Head Comparison<br><br>| Feature                  | Provider                      | BLoC                              |<br>|--------------------------|-------------------------------|-----------------------------------|<br>| Learning Curve           | Easy                          | Moderate to Difficult             |<br>| Boilerplate              | Minimal                       | High                              |<br>| Async Support            | Basic                         | Strong via Streams                |<br>| Scalability              | Medium                        | High                              |<br>| Code Separation          | Low                           | High (UI ↔ Business Logic)        |<br>| Best For                 | Simple to Medium Apps         | Large/Enterprise-level Apps       |<br>| Community Support        | Very Strong                   | Strong                            |<br><br>---<br><br>## 👨‍💻 Real-World Scenarios<br><br>- **Use Provider** if you’re building a recipe app, notes app, or something with simple UI interactions.<br>- **Use BLoC** for a social media app, e-commerce platform, or any app involving complex flows, API interactions, and role-based access.<br><br>---<br><br>## 📦 Can You Use Both Together?<br><br>Yes! Many developers start with Provider and later adopt BLoC as their app grows. You can even use Provider to inject BLoC classes, combining the best of both worlds.<br><br>```dart<br>Provider(<br>  create: (_) =&gt; MyBloc(),<br>  dispose: (_, bloc) =&gt; bloc.dispose(),<br>  child: MyApp(),<br>)</pre><h3>🧠 Final Thoughts</h3><ul><li><strong>Beginner?</strong> Start with Provider. It’s easier and less overwhelming.</li><li><strong>Working on a complex or team project?</strong> Consider BLoC for its scalability and structure.</li></ul><h3>🔖 Bonus Tip</h3><p>If you’re using <strong>FlutterFlow</strong>, <strong>Provider</strong> is already baked in, and you can customize your logic using Custom Actions. But if you move to raw Flutter, consider learning BLoC for more granular control.</p><h3>📣 Let’s Connect</h3><p>Follow me for more Flutter tips and tutorials:</p><ul><li><a href="https://medium.com/@kakadiyanirav25">Medium</a></li><li><a href="https://github.com/niravkakadiya25">GitHub</a></li><li><a href="https://coff.ee/niravkakadiya">Buy Me a Coffee</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d3e1bf51bfb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Mastering State Management in Flutter with BLoC Pattern]]></title>
            <link>https://medium.com/@kakadiyanirav25/mastering-state-management-in-flutter-with-bloc-pattern-487873063964?source=rss-a9e76cdb22c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/487873063964</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[bloc-pattern]]></category>
            <dc:creator><![CDATA[Nirav Kakadiya]]></dc:creator>
            <pubDate>Wed, 09 Jul 2025 11:54:44 GMT</pubDate>
            <atom:updated>2025-07-09T13:09:40.238Z</atom:updated>
            <content:encoded><![CDATA[<ul><li><strong>Getting Started with BLoC in Flutter: A Beginner’s Guide</strong></li><li>🚀 Mastering State Management in Flutter with BLoC Pattern</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sGRDkX-4xqAWELZ4e03XHA.png" /></figure><p>As your Flutter apps grow in complexity, managing state effectively becomes crucial. <strong>BLoC (Business Logic Component)</strong> is one of the most powerful patterns for maintaining scalable and testable applications.</p><p>In this guide, we’ll explore what BLoC is, why you should use it, and how to implement it in your Flutter project.</p><p>🌱 What is BLoC?</p><p><strong>BLoC</strong> stands for <em>Business Logic Component</em>. It’s a design pattern that separates the presentation layer from the business logic. Using Streams and Sinks, BLoC makes your Flutter code more maintainable and testable.</p><h3>🚀 Why Use BLoC?</h3><ul><li>Clear separation of concerns</li><li>Makes business logic testable</li><li>Works well in large applications</li><li>Reactive programming model</li></ul><h3>🧱 Key BLoC Concepts</h3><ul><li><strong>Events</strong>: Inputs into the BLoC</li><li><strong>States</strong>: Outputs of the BLoC</li><li><strong>BLoC</strong>: Handles incoming events and maps them to new states</li></ul><h3>⚙️ BLoC in Action — Counter Example</h3><p>Let’s build a simple counter app using the BLoC pattern.</p><ol><li>Create Event</li></ol><pre>abstract class CounterEvent {}<br><br>class Increment extends CounterEvent {}<br><br>class Decrement extends CounterEvent {}</pre><p>2. Create State</p><pre>class CounterState {<br>  final int count;<br>  CounterState(this.count);<br>}</pre><p>3. Create BLoC</p><pre>class CounterBloc extends Bloc&lt;CounterEvent, CounterState&gt; {<br>  CounterBloc() : super(CounterState(0)) {<br>    on&lt;Increment&gt;((event, emit) =&gt; emit(CounterState(state.count + 1)));<br>    on&lt;Decrement&gt;((event, emit) =&gt; emit(CounterState(state.count - 1)));<br>  }<br>}</pre><p>4. UI Integration</p><pre>BlocProvider(<br>  create: (_) =&gt; CounterBloc(),<br>  child: BlocBuilder&lt;CounterBloc, CounterState&gt;(<br>    builder: (context, state) {<br>      return Column(<br>        children: [<br>          Text(&#39;Counter: ${state.count}&#39;),<br>          Row(<br>            children: [<br>              ElevatedButton(<br>                onPressed: () =&gt; context.read&lt;CounterBloc&gt;().add(Increment()),<br>                child: Text(&#39;+&#39;),<br>              ),<br>              ElevatedButton(<br>                onPressed: () =&gt; context.read&lt;CounterBloc&gt;().add(Decrement()),<br>                child: Text(&#39;-&#39;),<br>              ),<br>            ],<br>          ),<br>        ],<br>      );<br>    },<br>  ),<br>);</pre><p>5. Testing Your BLoC</p><pre>void main() {<br>  blocTest&lt;CounterBloc, CounterState&gt;(<br>    &#39;emits [1] when Increment is added&#39;,<br>    build: () =&gt; CounterBloc(),<br>    act: (bloc) =&gt; bloc.add(Increment()),<br>    expect: () =&gt; [CounterState(1)],<br>  );<br>}</pre><p>📚 Best Practices</p><p>💡 Keep UI dumb; move logic to BLoC</p><p>💡 Use BlocProvider for injecting dependencies</p><p>💡 Use equatable to improve performance and equality checks</p><p>📦 Packages You’ll Need</p><ul><li><a href="https://pub.dev/packages/flutter_bloc"><em>flutter_bloc</em></a></li><li><a href="https://pub.dev/packages/equatable"><em>equatable</em></a></li><li><a href="https://pub.dev/packages/bloc_test"><em>bloc_test</em></a></li></ul><p>📌 Conclusion</p><p>Mastering the BLoC pattern will elevate your Flutter development game. It brings structure, scalability, and testability to your apps. While the learning curve might be steep at first, the benefits in larger apps are immense.</p><p><strong>Happy coding! 💙</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=487873063964" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>