<?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 Naveen Yadav on Medium]]></title>
        <description><![CDATA[Stories by Naveen Yadav on Medium]]></description>
        <link>https://medium.com/@naveenyadav4116?source=rss-9c4639e1c4be------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*R3rI9JXjVB28AypAmEd_DA.jpeg</url>
            <title>Stories by Naveen Yadav on Medium</title>
            <link>https://medium.com/@naveenyadav4116?source=rss-9c4639e1c4be------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 06:52:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@naveenyadav4116/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[Why, When and How to use Freezed]]></title>
            <link>https://medium.com/@naveenyadav4116/freezed-immutability-and-why-your-flutter-state-should-stop-lying-to-you-f63234bb2c7e?source=rss-9c4639e1c4be------2</link>
            <guid isPermaLink="false">https://medium.com/p/f63234bb2c7e</guid>
            <dc:creator><![CDATA[Naveen Yadav]]></dc:creator>
            <pubDate>Wed, 07 Jan 2026 07:23:18 GMT</pubDate>
            <atom:updated>2026-01-12T05:25:20.477Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Why, How, When to use Freezed</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yVWKkXy98OR4xpABF_5TLQ.jpeg" /></figure><p>Most Flutter bugs related to state are not caused by widgets or async code.<br> They are caused by <strong>models and state that allow contradictions</strong>.</p><p>Freezed is often introduced as a “boilerplate reducer”, but its real value is far deeper:<br> <strong>it makes invalid states unrepresentable</strong>.</p><p>This article explains Freezed and immutability through the <em>actual questions developers ask</em> — from basics to architectural correctness.</p><h3>Why This Topic Matters (Quick Context)</h3><p>Flutter’s UI is declarative, but many apps still use <strong>imperative state thinking</strong>:</p><ul><li>mutable objects</li><li>nullable fields</li><li>multiple boolean flags</li></ul><p>This mismatch is the root cause of subtle, recurring UI bugs.</p><p>Freezed fixes the model, not the symptoms.</p><h3>How Do You Actually Create a Freezed Class?</h3><p>Before understanding <em>why</em> Freezed works, developers need to see <strong>how little code is actually required</strong>.</p><h3>1. Add the required libraries</h3><pre>dependencies:<br>  freezed_annotation: ^3.0.1<br><br>dev_dependencies:<br>  freezed: ^3.2.4<br>  build_runner: ^2.10.4</pre><ul><li>freezed_annotation → used at runtime (annotations)</li><li>freezed → code generator (development only)</li><li>build_runner → runs the generator</li></ul><p>This split is intentional: <strong>Freezed runs once, the generated code runs forever</strong>.</p><h3>2. Write the model (this is all you write)</h3><pre>import &#39;package:freezed_annotation/freezed_annotation.dart&#39;;<br><br>// required: associates our `user.dart` with the code generated by Freezed<br>part &#39;user.freezed.dart&#39;;<br><br>@freezed<br>abstract class User with _$User {<br>  const factory User({<br>    required String firstName,<br>    required String lastName,<br>    required int age,<br>  }) = _User;<br>}</pre><p>Key points:</p><ul><li>The class is immutable by default</li><li>_User is a generated, private implementation</li><li>User is the only public API</li></ul><p>You never instantiate _User directly.</p><h3>3. Generate the code</h3><pre>dart run build_runner build --delete-conflicting-outputs</pre><p>or If Using Fvm</p><pre>fvm dart run build_runner build --delete-conflicting-outputs</pre><p>It will generate:</p><pre>user.freezed.dart</pre><ul><li>value equality</li><li>copyWith</li><li>toString</li><li>immutability guarantees</li></ul><p>You <strong>do not edit this file</strong> — it is a derived artifact.</p><h3>Optional: JSON support (common in real apps)</h3><p>If the model represents API data:</p><pre>dependencies:<br>  json_annotation: ^4.9.0<br><br>dev_dependencies:<br>  json_serializable: ^6.11.3</pre><pre>import &#39;package:freezed_annotation/freezed_annotation.dart&#39;;<br><br>// required: associates our `user.dart` with the code generated by Freezed<br>part &#39;user.freezed.dart&#39;;<br><br>part &#39;user.g.dart&#39;;<br><br>@freezed<br>abstract class User with _$User {<br>  const factory User({<br>    required String firstName,<br>    required String lastName,<br>    required int age,<br>  }) = _User;<br><br>  factory User.fromJson(Map&lt;String, dynamic&gt; json) =&gt; _$UserFromJson(json);<br>}</pre><p>Now the same model is:</p><ul><li>immutable</li><li>value-equal</li><li>JSON-safe</li></ul><h3>Why This Matters</h3><p>The developer effort is minimal:</p><ul><li>~10 lines of handwritten code</li><li>zero boilerplate maintenance</li></ul><p>Yet the guarantees are strong:</p><ul><li>no mutation</li><li>no invalid equality</li><li>no accidental state corruption</li></ul><p>This low-effort / high-safety ratio is exactly why Freezed fits so well in serious Flutter codebases.</p><h3>Q1. What problem does Freezed really solve?</h3><p>Freezed solves two fundamental issues:</p><ul><li><strong>Uncontrolled mutability</strong></li><li><strong>Contradictory or invalid state</strong></li></ul><p>It enforces:</p><ul><li>immutability</li><li>value equality</li><li>explicit state modeling</li></ul><p>The result: <strong>bugs move from runtime to compile time</strong>.</p><h3>Q2. Why is immutability essential in Flutter?</h3><p>Immutability means objects cannot be changed after creation.</p><p>Instead of mutating:</p><pre>user.age = 31;</pre><p>You replace:</p><pre>user = user.copyWith(age: 31);</pre><p>Why this matters:</p><ul><li>Flutter rebuilds depend on <strong>new references</strong></li><li>Mutation can fail silently</li><li>Debugging becomes non-deterministic</li></ul><p>Immutability makes state transitions <strong>predictable and observable</strong>.</p><h3>Q3. What does Freezed generate for you?</h3><p>A simple Freezed model:</p><pre>@freezed<br>abstract class User with _$User {<br>  const factory User({<br>    required String id,<br>    required String name,<br>    required int age,<br>  }) = _User;<br>}</pre><p>Generates automatically:</p><ul><li>== and hashCode (value equality)</li><li>copyWith</li><li>toString</li><li>immutability guarantees</li></ul><p>This removes boilerplate <em>and</em> prevents incorrect implementations.</p><h3>Q4. Why does Freezed force factory constructors?</h3><p>Because Freezed:</p><ul><li>controls object creation</li><li>generates private implementation classes</li><li>enables sealed/union types</li></ul><pre>const factory User(...) = _User;</pre><p>Normal constructors cannot support this model.</p><p>Important:<br> Freezed factories are <strong>not for logic or side effects</strong>.<br> Computation belongs in getters, named factories, or mappers.</p><h3>Q5. Does copyWith mutate the original object?</h3><p>No. Ever.</p><pre>final user1 = User(age: 30);<br>final user2 = user1.copyWith(age: 31);</pre><ul><li>user1 is unchanged</li><li>user2 is a new instance</li></ul><p>In Flutter, <strong>state is replaced, not mutated</strong>.</p><h3>Q6. How do contradictory states happen in real apps?</h3><p>Most apps model state like this:</p><pre>bool isLoading;<br>String? error;<br>User? data;</pre><p>This allows impossible combinations:</p><ul><li>isLoading == true and error != null</li><li>data != null and isLoading == true</li><li>error != null and data != null</li></ul><p>These contradictions are <strong>not runtime errors</strong> — they are <em>design flaws</em>.<br> The compiler cannot help you.</p><h3>Q7. How does Freezed prevent contradictory state?</h3><p>By modeling state as <strong>explicit, mutually exclusive variants</strong>:</p><pre>@freezed<br>sealed class UserState&lt;T&gt; with _$UserState&lt;T&gt; {<br>  const factory UserState.loading() = Loading&lt;T&gt;;<br><br>  const factory UserState.success(T data) = Success&lt;T&gt;;<br><br>  const factory UserState.error(String message) = Error&lt;T&gt;;<br>}</pre><p>Now:</p><ul><li>only one state can exist at a time</li><li>invalid combinations are impossible</li><li>missing cases cause compile-time errors</li></ul><p>This is <strong>state integrity</strong>, not syntax sugar.</p><h3>Before vs After (Mental Model)</h3><h3>❌ Before (Flag-based state)</h3><pre>loading = true<br>error = &quot;Failed&quot;<br>data = User(...)</pre><p>UI logic becomes defensive and fragile.</p><h3>✅ After (Freezed union state)</h3><pre>UserState.loading()<br>UserState.success(user)<br>UserState.error(message)</pre><p>One state. One truth. No contradictions.</p><h3>Q8. What are when and map, and how are they different?</h3><p>Both are pattern matching tools, generated automatically.</p><h3>when — match on data</h3><pre>state.when(<br>  loading: () =&gt; Spinner(),<br>  success: (user) =&gt; Text(user.name),<br>  error: (msg) =&gt; Text(msg),<br>);</pre><p>Best for UI.</p><h3>map — match on state type</h3><pre>state.map(<br>  loading: (_) =&gt; CircularProgressIndicator()<br>  success: (s) =&gt; Text(s.user.name),<br>  error: (e) =&gt; Text(e.message),<br>);</pre><p>Useful for advanced or state-specific logic.</p><p><strong>Rule of thumb</strong></p><ul><li>UI → when</li><li>Logic → map</li></ul><h3>Q9. How should Freezed fit into Clean Architecture?</h3><p>Correct flow:</p><pre>API JSON<br> → DTO (Freezed + JSON)<br> → Domain Entity (Freezed, no JSON)<br> → UI / State</pre><p>DTOs reflect external contracts.<br> Domain entities reflect business meaning.</p><p>Mapping isolates API changes and protects your core logic.</p><h3>Q10. Why use a mapper instead of converting inside the model?</h3><p>Because mapping is a <strong>translation concern</strong>, not a model concern.</p><p>Using extensions:</p><ul><li>avoids layer coupling</li><li>keeps responsibilities clear</li><li>scales when APIs evolve</li></ul><p>This is architectural discipline, not over-engineering.</p><h3>When Should You Use (and Avoid) Freezed?</h3><h3>Use Freezed when:</h3><ul><li>state has multiple valid forms</li><li>correctness matters</li><li>refactoring is expected</li><li>the app is non-trivial</li></ul><h3>Avoid Freezed when:</h3><ul><li>models are trivial and short-lived</li><li>mutation is intentional and safe</li><li>performance-critical hot paths demand it</li></ul><h3>Final Takeaway</h3><p>Freezed is not about writing less code.</p><p>It is about:</p><ul><li>preventing impossible states</li><li>enforcing immutability</li><li>making the compiler work for you</li></ul><p>When used correctly, Freezed doesn’t just improve code style — <br> it <strong>raises the correctness ceiling of your entire Flutter app</strong>.</p><p><em>If anything doesn’t make sense, or you’re curious to dive deeper, don’t hesitate to ask. I’m always up for a conversation, and who knows, we might just uncover something new together.</em></p><p><a href="https://www.paypal.com/ncp/payment/ZXET7GZZB8EH6"><em>Buy me a coffee! ☕️</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f63234bb2c7e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why use CONST in Flutter?]]></title>
            <link>https://medium.com/@naveenyadav4116/why-use-const-in-flutter-45c6b6743d0f?source=rss-9c4639e1c4be------2</link>
            <guid isPermaLink="false">https://medium.com/p/45c6b6743d0f</guid>
            <category><![CDATA[memory-improvement]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[const]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Naveen Yadav]]></dc:creator>
            <pubDate>Wed, 11 Sep 2024 13:41:13 GMT</pubDate>
            <atom:updated>2024-09-11T13:52:07.585Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*APYimRgBupRr54Hzf_Rzqg.jpeg" /><figcaption>Be Alive</figcaption></figure><p>In Flutter (and Dart in general), using const in front of a class constructor makes instances of that class <strong>compile-time constants</strong>. This is beneficial for performance optimization and memory management because objects created with const are immutable and can be reused.</p><h3>What Happens When You Use Const Before a Class Constructor?</h3><ol><li><strong>Compile-Time Constant</strong>: The object is created during compile-time instead of runtime, meaning the instance is immutable and predefined. If two or more const objects are created with the same constructor and the same parameters, the Dart compiler reuses the same instance in memory.</li><li><strong>Immutability</strong>: Any object created with a const constructor is immutable, meaning you cannot change its properties once it’s created.</li><li><strong>Memory Efficiency</strong>: Because const objects are immutable, Flutter reuses them, making your app more memory-efficient. Dart uses object canonicalization, meaning that multiple instances of a const object with the same values will point to the same object reference.</li></ol><h3>Basic Example of Using const</h3><p>Here’s an example where we create a class with a const constructor:</p><pre>class MyClass {<br>  final int x;<br><br>  // const constructor<br>  const MyClass(this.x);<br>}<br><br>void main() {<br>  const first = MyClass(10);<br>  const second = MyClass(10);<br>  const third= MyClass(20);<br>  var fourth = MyClass(20);<br><br>  // first and second refer to the same instance<br>  print(identical(first, second)); // true<br><br>  // third is different because it has a different value<br>  print(identical(first, third)); // false<br><br>  // fourth is different because it is not const<br>  print(identical(third, fourth)); // false<br>}</pre><h3>Explanation:</h3><ul><li><strong>first</strong> and <strong>second</strong> are both instances of <em>MyClass(10)</em>,and are marked const. Since the constructor and values are identical, Dart reuses the same memory location for both.</li><li><strong>third</strong> has a different value, so it’s a separate instance, even though it’s also created using <em>const</em>.</li><li><strong>fourth</strong> will <em>NOT</em> be the same as <em>third</em>, even though both <em>third</em> and <em>fourth</em> have the same value (20). This is because fourth is created without the const keyword, so it is treated as a regular runtime object, while <em>third</em> is a compile-time constant.</li></ul><h3>Use Cases of const in Flutter</h3><ol><li><strong>Widget Trees (Stateless Widgets): </strong>One of the most common use cases in Flutter is using const in widget trees for stateless widgets. Since stateless widgets are immutable by nature, marking them as const allows Flutter to optimize rendering by reusing widgets that don’t need to be rebuilt.</li></ol><p>Example:</p><pre>class MyStatelessWidget extends StatelessWidget {<br>  final String text;<br><br>  // const constructor<br>  const MyStatelessWidget(this.text);<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Text(text);<br>  }<br>}<br><br>void main() {<br>  const widget1 = MyStatelessWidget(&#39;Hello&#39;);<br>  const widget2 = MyStatelessWidget(&#39;Hello&#39;);<br><br>  print(identical(widget1, widget2)); // true<br>}</pre><p>In this example, widget1 and widget2 are the same object because they are both const with identical values.</p><ol><li><strong>Preventing Unnecessary Rebuilds: </strong>If you use <em>const</em> in a widget tree, Flutter knows it doesn’t need to rebuild that widget when the state changes, because the widget and its properties are immutable.</li></ol><pre>const Icon(Icons.star);  // Will not be rebuilt</pre><p>Using <em>const</em> with an <em>Icon</em> widget means it won’t be rebuilt unnecessarily during setState calls.</p><p><strong>2. Complex Widget Trees: </strong>In complex UIs where many widgets are created, using const wherever possible can help Flutter reduce the workload during rebuilds. Since const widgets are treated as constants, Flutter doesn’t need to reconstruct them every time a parent widget rebuilds.</p><p>Example:</p><pre>@override<br>Widget build(BuildContext context) {<br>  return const Column(<br>    children: [<br>      Text(&#39;Hello, World!&#39;),<br>      Icon(Icons.star),<br>    ],<br>  );<br>}</pre><p>By using const, you ensure that the Column, Text, and Icon widgets are not recreated during subsequent builds.</p><p><strong>3. Reusable Styles and Colors: </strong>You can also use <em>const</em> with classes like <em>TextStyle</em>, <em>BoxDecoration</em>, and <em>Color</em>. This ensures that these objects are created once and reused across the app.</p><p>Example:</p><pre>const TextStyle myStyle = TextStyle(<br>  fontSize: 20,<br>  color: Colors.blue,<br>);<br><br>@override<br>Widget build(BuildContext context) {<br>  return const Text(<br>    &#39;Styled Text&#39;,<br>    style: myStyle,<br>  );<br>}</pre><p>The TextStyle is created once as a constant, and the Text widget reuses it.</p><p><strong>4. Lists, Maps, and Other Collections: </strong>Collections like List and Map can also be declared const. Once declared, these collections cannot be modified.</p><p>Example:</p><pre>const List&lt;int&gt; myList = [1, 2, 3];<br><br>void main() {<br>  // myList.add(4); // This will throw an error because myList is constant<br>}</pre><p>By marking the list as const, you ensure that it remains immutable and no elements can be added, removed, or changed.</p><h3>When NOT to Use const</h3><ul><li><strong>Mutable Objects</strong>: If you need to change the properties of an object after its creation, do not use <em>const</em>. <em>const</em> objects are immutable by definition.</li><li><strong>Dynamic Data</strong>: If you are fetching data from APIs or databases that change over time, you cannot use <em>const</em> for such objects because they need to be created at runtime with changing values.</li></ul><h3>Conclusion</h3><p>Using const in front of a class constructor or in collections ensures immutability and enables Dart’s optimizations like object reuse and performance improvement. It’s especially useful in Flutter widget trees to avoid unnecessary rebuilds and improve memory efficiency. However, const should only be used when the object is immutable, and values are known at compile-time.</p><p><em>If anything doesn’t make sense, or you’re curious to dive deeper, don’t hesitate to ask. I’m always up for a conversation, and who knows, we might just uncover something new together.</em></p><p><a href="https://www.paypal.com/ncp/payment/ZXET7GZZB8EH6"><em>Buy me a coffee! ☕️</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45c6b6743d0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering SOLID Principles: Simplified for Everyone]]></title>
            <link>https://medium.com/@naveenyadav4116/mastering-solid-principles-simplified-for-everyone-8033dffff1bf?source=rss-9c4639e1c4be------2</link>
            <guid isPermaLink="false">https://medium.com/p/8033dffff1bf</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[liskov-substitution]]></category>
            <category><![CDATA[open-closed-principle]]></category>
            <category><![CDATA[single-responsibility]]></category>
            <category><![CDATA[solid]]></category>
            <dc:creator><![CDATA[Naveen Yadav]]></dc:creator>
            <pubDate>Tue, 03 Sep 2024 11:11:14 GMT</pubDate>
            <atom:updated>2024-09-11T13:51:44.030Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4wCFqHzp4oIOn3B-v9WP_w.jpeg" /><figcaption>SOLID bridge</figcaption></figure><p>As developers, we’re always looking for ways to write better code — code that’s clean, easy to understand, and easy to maintain. One of the best ways to achieve this is by following the SOLID principles. These principles might sound complicated initially, but they’re pretty simple when you break them down. Let’s dive into each one with an easy-to-understand example.</p><h4>S — Single Responsibility Principle (SRP)</h4><p><strong>What It Means: </strong>Every class or module in your code should have one job and only one job.</p><p><strong>Example: </strong>Imagine you have a toy box. Putting all your toys in one box will take much work to find what you need. But if you have one box for your cars, another for your action figures, and another for your dolls, it’s much easier to keep things organized. Each box has a single responsibility: to hold a specific type of toy.</p><p><strong>In Code: </strong>Think of a class that handles only one thing, like managing user information. It shouldn’t be responsible for sending emails or saving data to a database. Just like the toy boxes, it’s easier to manage and find what you need when everything has its own place.</p><h4>O — Open/Closed Principle (OCP)</h4><p><strong>What It Means: </strong>Your code should be open for extension but closed for modification.</p><p><strong>Example: </strong>Imagine you have a set of LEGO bricks. You can build new things by adding more bricks, but you don’t have to break down what you’ve already built. Your existing creation stays intact, and you just keep adding more pieces.</p><p><strong>In Code: </strong>When you write a piece of code, like a function or a class, it should work without needing to be changed whenever you want to add new features. Instead, you add new code that extends the existing functionality, just like adding more LEGO bricks to your creation.</p><h4>L — Liskov Substitution Principle (LSP)</h4><p><strong>What It Means: </strong>Objects of a subclass should be able to replace objects of the superclass without affecting the functionality.</p><p><strong>Example: </strong>Let’s say you have a remote-controlled car. You can switch out the battery with another battery, and the car should still work fine. It doesn’t matter which brand of battery you use as long as it fits and works with the car.</p><p><strong>In Code: </strong>If you have a base class, like a Vehicle, and subclasses, like a Car or Bike, you should be able to use a Bike wherever you’re using a Vehicle without breaking anything. It should just work, like swapping out the batteries in your toy.</p><h4>I — Interface Segregation Principle (ISP)</h4><p><strong>What It Means: </strong>A class should not be forced to implement interfaces it doesn’t use.</p><p><strong>Example: </strong>Imagine you have a lunchbox that has separate compartments for different foods. You wouldn’t want your sandwich stuck in the soup compartment, right? Each compartment is designed for a specific purpose, and you only use the needed ones.</p><p><strong>In Code: </strong>If you have an interface that defines multiple methods, a class should only implement the methods it actually uses. For example, if you have an interface for a Printer, and one class is for a 3DPrinter and another for a LaserPrinter, each should only implement the methods relevant to their type of printing. They shouldn’t have to deal with methods they don’t need.</p><h4>D — Dependency Inversion Principle (DIP)</h4><p><strong>What It Means: </strong>Depends on abstractions, not on concrete implementations.</p><p><strong>Example: </strong>Imagine you’re building a toy train set. Instead of permanently glueing the tracks down, you can use connectors to swap out tracks whenever you want. This way, you can easily change the layout without rebuilding everything.</p><p><strong>In Code: </strong>If your class depends on another class, it should depend on an interface or an abstract class, not a specific implementation. This allows you to switch out the implementation easily, just like swapping out the train tracks. For example, if you have a PaymentProcessor class, it should depend on an interface like PaymentMethod rather than a specific class like CreditCard. This way, you can easily add new payment methods like PayPal or ApplePay without changing the PaymentProcessor class.</p><p>Understanding and applying these principles makes your code more accessible to manage, extend, and maintain. Think of them as your coding toolkit — each tool has a specific purpose, and when used correctly, they help you build something great.</p><p><em>If anything doesn’t make sense, or you’re curious to dive deeper, don’t hesitate to ask. I’m always up for a conversation, and who knows, we might just uncover something new together.</em></p><p><a href="https://www.paypal.com/ncp/payment/ZXET7GZZB8EH6"><em>Buy me a coffee! ☕️</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8033dffff1bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Flutter is More Than Just a Framework — It’s a Game-Changer ]]></title>
            <link>https://medium.com/@naveenyadav4116/why-flutter-is-more-than-just-a-framework-its-a-game-changer-c5ee321c477d?source=rss-9c4639e1c4be------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5ee321c477d</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[why-choose-flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[learning-and-development]]></category>
            <dc:creator><![CDATA[Naveen Yadav]]></dc:creator>
            <pubDate>Sun, 25 Aug 2024 09:55:24 GMT</pubDate>
            <atom:updated>2024-08-25T10:10:08.627Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why Flutter is More Than Just a Framework — It’s a Game-Changer 🚀</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*czApHyqH--rRjU8V9Ey4dw.png" /></figure><p>Let me share a story that might hit home for a lot of you. A few years back, I was deep in the trenches of app development, juggling multiple frameworks like a circus performer. Every project felt like a maze of compromises — Android, iOS, different UIs, performance issues… It was exhausting. And then, I discovered Flutter.</p><p>I know what you’re thinking — “Another framework to learn?” But trust me, this one’s different. Flutter is more than just a new tool in your kit; it’s a game-changer. Here’s why:</p><p><strong>1. One Codebase, Two Platforms:</strong> Imagine cutting your development time in half by writing one codebase for both Android and iOS. That’s what Flutter offers. No more rewriting the same app for different platforms. More time to innovate, less time fixing bugs.</p><p><strong>2. Stunning UIs with Ease:</strong> With Flutter, creating beautiful, custom UIs is no longer a chore. Its rich set of pre-designed widgets and customizable components lets you build visually appealing apps that stand out from the crowd — all without compromising performance.</p><p><strong>3. Hot Reload = Instant Gratification:</strong> Remember the frustration of waiting for your app to compile just to see a small UI change? Flutter’s hot reload feature lets you see your changes in real-time, boosting productivity and making the development process feel, dare I say, fun.</p><p><strong>4. Consistent Performance:</strong> Flutter doesn’t just make development easier; it also ensures your app runs smoothly. Whether it’s a complex animation or a simple button press, the performance is seamless across both platforms, keeping your users happy and engaged.</p><p><strong>5. Growing Community &amp; Ecosystem:</strong> Flutter’s community is booming. You’re not alone in this journey. With a wealth of packages, plugins, and resources at your disposal, plus an active community ready to help, you can overcome any hurdle with confidence.</p><p>So, if you’re a developer who’s tired of the old routine and ready to up your game, give Flutter a shot. It’s not just about building apps — it’s about building better, faster, and with more satisfaction.</p><p>And if you’ve already taken the plunge into Flutter, share your experience. Let’s swap stories, tips, and maybe a few war wounds. After all, the journey is better when we walk it together.</p><p>And at last, Keep up the good work!😉</p><h3>#Flutter #MobileDevelopment #AppDev #Programming #TechStory #Efficiency #Innovation #DeveloperLife</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5ee321c477d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Guide for Intermediate Developers: Navigating the Flutter Development Journey]]></title>
            <link>https://medium.com/@naveenyadav4116/a-guide-for-intermediate-developers-navigating-the-flutter-development-journey-a3e1d213ecc0?source=rss-9c4639e1c4be------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3e1d213ecc0</guid>
            <dc:creator><![CDATA[Naveen Yadav]]></dc:creator>
            <pubDate>Sat, 03 Feb 2024 08:11:47 GMT</pubDate>
            <atom:updated>2024-02-03T08:11:47.790Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fa6DpUiI-LWU99YDhzXdvA.jpeg" /></figure><p>Hey Flutter Enthusiasts! 👋</p><p>So, you’ve conquered the basics of Flutter and you’re ready to dive into the world of intermediate development. Congratulations! In this blog, we’re going to walk you through the crucial decisions you’ll need to make to develop a robust Flutter project. From choosing your project approach to selecting the right state management and architecture, we’ve got you covered. Let’s jump right in!</p><h3>1. Choosing Your Project Approach</h3><p>Before you start coding, take a moment to think about your project approach. Are you building a mobile app, a web app, or perhaps both? Flutter allows you to create applications for various platforms from a single codebase. Decide on your target platforms, and Flutter will do the heavy lifting for you.</p><p>Ask yourself:</p><ul><li>What is the primary goal of my project?</li><li>Who is the target audience?</li><li>What platforms do I want to support?</li></ul><p>Understanding these questions will help you define the scope and scale of your project.</p><h3>2. Defining Project Components</h3><p>Now that you have a clear vision, break down your project into components. Identify key features and functionalities. Sketch out a rough user interface. This blueprint will serve as your roadmap throughout development.</p><p>Consider:</p><ul><li>User Interface: What will the user see and interact with?</li><li>Functionality: What actions should the app perform?</li><li>Data Management: How will data be stored and retrieved?</li></ul><p>This step is crucial for avoiding scope creep and staying focused throughout the development process.</p><h3>3. Choosing State Management</h3><p>Ah, state management — the heart of any Flutter application. As an intermediate developer, you’re likely familiar with the setState method, but for larger projects, you’ll need something more robust.</p><p>Options include:</p><ul><li><strong>Provider:</strong> A simple and efficient state management solution.</li><li><strong>Bloc:</strong> Ideal for managing complex state and business logic.</li><li><strong>GetX:</strong> A lightweight and easy-to-use option.</li></ul><p>Evaluate your project’s complexity and choose a state management solution that aligns with your needs.</p><h3>4. Selecting the Right Architecture</h3><p>Architectural decisions can make or break a project. Flutter offers flexibility in choosing your architecture, so don’t rush this step.</p><p>Common architectures include:</p><ul><li><strong>MVC (Model-View-Controller)</strong>: Simple and straightforward.</li><li><strong>MVVM (Model-View-ViewModel)</strong>: Ideal for data-binding and testability.</li><li><strong>Bloc Pattern:</strong> Perfect for reactive programming and handling complex state.</li></ul><p>Consider factors like scalability, maintainability, and your team’s familiarity when picking an architecture.</p><h3>Conclusion</h3><p>Congratulations! You’ve just embarked on your journey to intermediate Flutter development. Remember, every project is a learning opportunity, so don’t be afraid to experiment and push your boundaries. Stay curious, keep coding, and soon you’ll be crafting Flutter masterpieces. Happy coding, Flutteristas! 🚀</p><p><em>Stay tuned for more tips, tricks, and Flutter adventures!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3e1d213ecc0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Razorpay Integration with Flutter]]></title>
            <link>https://medium.com/@naveenyadav4116/razorpay-integration-with-flutter-df9ecb8a810a?source=rss-9c4639e1c4be------2</link>
            <guid isPermaLink="false">https://medium.com/p/df9ecb8a810a</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[payments]]></category>
            <category><![CDATA[payment-gateway]]></category>
            <category><![CDATA[razorpay]]></category>
            <dc:creator><![CDATA[Naveen Yadav]]></dc:creator>
            <pubDate>Mon, 29 Jul 2019 07:28:57 GMT</pubDate>
            <atom:updated>2019-08-01T08:10:23.370Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kv_UI7B1hWy-iUaP" /><figcaption>Photo by <a href="https://unsplash.com/@nate_dumlao?utm_source=medium&amp;utm_medium=referral">Nathan Dumlao</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Razor Pay is one of the payment gateway which provided plugin in flutter. So we can easily use it like any other package.</p><blockquote>Build a secure payment solution on your website or mobile app with Razorpay and receive payments from your customers using various payment methods on your Checkout form. You can track payments at every step of its life cycle and effectively manage them.</blockquote><p>Go and add this package in your pubspec.yaml file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/230/1*sW8q44c-bf2jq1APaZwYkw.png" /></figure><p>And run the command</p><blockquote><strong><em>flutter packages get</em></strong></blockquote><p>Now make a Razorpay class and the response class.</p><pre>import &#39;package:flutter/services.dart&#39;;<br><br>import &#39;package:eventify/eventify.dart&#39;;<br><br>class Razorpay {<br>  // Response codes from platform<br>  static const _CODE_PAYMENT_SUCCESS = 0;<br>  static const _CODE_PAYMENT_ERROR = 1;<br>  static const _CODE_PAYMENT_EXTERNAL_WALLET = 2;<br><br>  // Event names<br>  static const EVENT_PAYMENT_SUCCESS = &#39;payment.success&#39;;<br>  static const EVENT_PAYMENT_ERROR = &#39;payment.error&#39;;<br>  static const EVENT_EXTERNAL_WALLET = &#39;payment.external_wallet&#39;;<br><br>  // Payment error codes<br>  static const NETWORK_ERROR = 0;<br>  static const INVALID_OPTIONS = 1;<br>  static const PAYMENT_CANCELLED = 2;<br>  static const TLS_ERROR = 3;<br>  static const INCOMPATIBLE_PLUGIN = 4;<br>  static const UNKNOWN_ERROR = 100;<br><br>  static const MethodChannel _channel = const MethodChannel(&#39;razorpay_flutter&#39;);<br><br>  // EventEmitter instance used for communication<br>  EventEmitter _eventEmitter;<br><br>  Razorpay() {<br>    _eventEmitter = new EventEmitter();<br>  }<br><br>  /// Opens Razorpay checkout<br>  void open(Map&lt;String, dynamic&gt; options) async {<br>    Map&lt;String, dynamic&gt; validationResult = _validateOptions(options);<br><br>    if (!validationResult[&#39;success&#39;]) {<br>      _handleResult({<br>        &#39;type&#39;: _CODE_PAYMENT_ERROR,<br>        &#39;data&#39;: {<br>          &#39;code&#39;: INVALID_OPTIONS,<br>          &#39;message&#39;: validationResult[&#39;message&#39;]<br>        }<br>      });<br>      return;<br>    }<br><br>    var response = await _channel.invokeMethod(&#39;open&#39;, options);<br>    print(&quot;print the response of payment success-full-----------\n ${response}&quot;);<br>    _handleResult(response);<br>  }<br><br>  /// Handles checkout response from platform<br>  void _handleResult(Map&lt;dynamic, dynamic&gt; response) {<br>    String eventName;<br>    Map&lt;dynamic, dynamic&gt; data = response[&quot;data&quot;];<br><br>    dynamic payload;<br><br>    switch (response[&#39;type&#39;]) {<br>      case _CODE_PAYMENT_SUCCESS:<br>        eventName = EVENT_PAYMENT_SUCCESS;<br>        payload = PaymentSuccessResponse.fromMap(data);<br>        break;<br><br>      case _CODE_PAYMENT_ERROR:<br>        eventName = EVENT_PAYMENT_ERROR;<br>        payload = PaymentFailureResponse.fromMap(data);<br>        break;<br><br>      case _CODE_PAYMENT_EXTERNAL_WALLET:<br>        eventName = EVENT_EXTERNAL_WALLET;<br>        payload = ExternalWalletResponse.fromMap(data);<br>        break;<br><br>      default:<br>        eventName = &#39;error&#39;;<br>        payload =<br>            PaymentFailureResponse(UNKNOWN_ERROR, &#39;An unknown error occurred.&#39;);<br>    }<br><br>    _eventEmitter.emit(eventName, null, payload);<br>  }<br><br>  /// Registers event listeners for payment events<br>  void on(String event, Function handler) {<br>    EventCallback cb = (event, cont) {<br>      handler(event.eventData);<br>    };<br>    _eventEmitter.on(event, null, cb);<br>    _resync();<br>  }<br><br>  /// Clears all event listeners<br>  void clear() {<br>    _eventEmitter.clear();<br>  }<br><br>  /// Retrieves lost responses from platform<br>  void _resync() async {<br>    var response = await _channel.invokeMethod(&#39;resync&#39;);<br>    if (response != null) {<br>      _handleResult(response);<br>    }<br>  }<br><br>  /// Validate payment options<br>  static Map&lt;String, dynamic&gt; _validateOptions(Map&lt;String, dynamic&gt; options) {<br>    var key = options[&#39;key&#39;];<br>    if (key == null) {<br>      return {<br>        &#39;success&#39;: false,<br>        &#39;message&#39;: &#39;Key is required. Please check if key is present in options.&#39;<br>      };<br>    }<br>    return {&#39;success&#39;: true};<br>  }<br><br>  <br>}<br><br>class PaymentSuccessResponse {<br>  String paymentId;<br>  String orderId;<br>  String signature;<br><br>  PaymentSuccessResponse(this.paymentId, this.orderId, this.signature);<br><br>  static PaymentSuccessResponse fromMap(Map&lt;dynamic, dynamic&gt; map) {<br>    String paymentId = map[&quot;razorpay_payment_id&quot;];<br>    String signature = map[&quot;razorpay_signature&quot;];<br>    String orderId = map[&quot;razorpay_order_id&quot;];<br><br>    return new PaymentSuccessResponse(paymentId, orderId, signature);<br>  }<br>}<br><br>class PaymentFailureResponse {<br>  int code;<br>  String message;<br><br>  PaymentFailureResponse(this.code, this.message);<br><br>  static PaymentFailureResponse fromMap(Map&lt;dynamic, dynamic&gt; map) {<br>    var code = map[&quot;code&quot;] as int;<br>    var message = map[&quot;message&quot;] as String;<br>    return new PaymentFailureResponse(code, message);<br>  }<br>}<br><br>class ExternalWalletResponse {<br>  String walletName;<br><br>  ExternalWalletResponse(this.walletName);<br><br>  static ExternalWalletResponse fromMap(Map&lt;dynamic, dynamic&gt; map) {<br>    var walletName = map[&quot;external_wallet&quot;] as String;<br>    return new ExternalWalletResponse(walletName);<br>  }<br>}</pre><p>Here we have defined the <em>Razorpay class </em>and<em> </em>defined different class to deal with the response.</p><blockquote><em>Step 1. Now you initialize the </em>Razorpay<em> class .</em></blockquote><blockquote><em>Razorpay</em> _razorpay = <em>Razorpay</em>();</blockquote><blockquote><em>Step 2. Initialize the details in options(pass your </em>Razorpay<em> key Id here. if you don’t have one go </em><a href="https://razorpay.com/docs/payment-gateway/flutter-integration/#generate-api-key"><em>here</em></a><em>.)</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*VecrGaJYyFPWwsNG1ZHTEw.png" /><figcaption>Options</figcaption></figure><blockquote>Step 3. Call open function and pass the options in there.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*bKqkx7ufGH2B8NJaIR33YA.png" /></figure><p>Here we have used a stateful class and then we have called FutureBuilder and called the open function in future.</p><blockquote>Step 4. Add the <em>listener</em> of anything happening in the payment gateway.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*YipfTP4cEz6LbwCYRXbaew.png" /><figcaption>Added event Listener</figcaption></figure><blockquote>Step 5. Now define how you handle the different <em>response</em>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*E2LtMYvOy2fb7ANaREYYXQ.png" /><figcaption>Handle response</figcaption></figure><p>Also don’t forget to call the clear function which is used to clear all event listeners</p><p>Does this solved your problem?</p><p>Also for reference you can check the Razorpay docs <a href="https://razorpay.com/docs/payment-gateway/flutter-integration/">here</a>.</p><p>Now you can use this Razorpay payment integration in your project. It’d be awesome to hear from you in the comments!</p><p>You can find link to GitHub repository <a href="https://github.com/naveenyadav15/razorpay_example">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df9ecb8a810a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playing with calendar carousel]]></title>
            <link>https://medium.com/@naveenyadav4116/playing-with-calendar-carousel-92238849e20c?source=rss-9c4639e1c4be------2</link>
            <guid isPermaLink="false">https://medium.com/p/92238849e20c</guid>
            <category><![CDATA[colors]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[calendar]]></category>
            <category><![CDATA[icons]]></category>
            <dc:creator><![CDATA[Naveen Yadav]]></dc:creator>
            <pubDate>Sun, 24 Feb 2019 16:56:56 GMT</pubDate>
            <atom:updated>2024-08-26T07:50:07.537Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GXn1wDTGETPm8TdUGMdKVg.png" /><figcaption>Final Image</figcaption></figure><blockquote>🚀 <strong><em>Update Alert!</em></strong> 🎉 <strong><em>Now compatible with the latest Flutter version — 3.24.1, and flutter_calendar_carousel package updates.</em></strong></blockquote><p>In the below example, I have shown how to mark dates with different colour I have taken two cases where a student is absent or present.</p><p>We have used two files first main.dart and other calendar.dart. In main.dart I have just defined the material app. Our calendar is implemented in calendar.dart.</p><ol><li>We have use calendar carousel. You need to add this dependency in your “pubspec.yaml”</li></ol><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  flutter_calendar_carousel: ^2.4.3</pre><p>2. Now import these packages in our calendar.dart</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter_calendar_carousel/flutter_calendar_carousel.dart&#39;;<br>import &#39;package:flutter_calendar_carousel/classes/event.dart&#39;;</pre><p>3. Now we will achieve this with the help of event. So make an icon (Colour you want to assign ) you want to show on dates.</p><pre>  static Widget _presentIcon(String day) =&gt; CircleAvatar(<br>    backgroundColor: Colors.green,<br>    child: Text(<br>      day,<br>      style: const TextStyle(<br>        color: Colors.black,<br>      ),<br>    ),<br>  );</pre><p>4. Now we define a variable EventList .</p><pre> final EventList&lt;Event&gt; _markedDateMap = EventList&lt;Event&gt;(<br>    events: &lt;DateTime, List&lt;Event&gt;&gt;{},<br>  );</pre><p>5. Now we add events to the list.</p><p>Here variable len is the fixed length we have provided and the dates are added via for loop.</p><p>Here we have taken two types of icon to show on dates one is absent and one is present.</p><p>6. Here presentDates and absentDates is the list of dates define globally.</p><pre> void markTheDates() {<br>    /// This function is used to mark the added dates,<br>    for (int index = 0; index &lt; presentDates.length; index++) {<br>      _markedDateMap.add(<br>        presentDates[index],<br>        Event(<br>          date: presentDates[index],<br>          title: &#39;Present&#39;,<br>          icon: _presentIcon(presentDates[index].day.toString()),<br>        ),<br>      );<br>    }<br><br>    for (int index = 0; index &lt; absentDates.length; index++) {<br>      _markedDateMap.add(<br>        absentDates[index],<br>        Event(<br>          date: absentDates[index],<br>          title: &#39;Absent&#39;,<br>          icon: _absentIcon(absentDates[index].day.toString()),<br>        ),<br>      );<br>    }<br>  }</pre><p>7. Now we take a variable of calendar.</p><pre>late CalendarCarousel&lt;Event&gt; _calendarCarouselNoHeader;</pre><p>8. Now we customize the carousel calendar.</p><pre>void initializeCalendarCarousal(){<br>    /// This function is used to initializing calendar carousal<br>    _calendarCarouselNoHeader = CalendarCarousel&lt;Event&gt;(<br>      height: cHeight * 0.54,<br>      weekendTextStyle: const TextStyle(<br>        color: Colors.red,<br>      ),<br>      todayButtonColor: Colors.blue.shade200,<br>      markedDatesMap: _markedDateMap,<br>      markedDateShowIcon: true,<br>      markedDateIconMaxShown: 1,<br>      markedDateMoreShowTotal: null,<br>      // null for not showing hidden events indicator<br>      markedDateIconBuilder: (event) {<br>        return event.icon;<br>      },<br>    );<br>  }</pre><p>Here we define the Height of calendar.</p><p>We have initialized the weekendTextStyle to show in different color</p><p>We have changed todayButtonColor to blue</p><p>Now we have initialized the eventList to markedDatesMap [ this is where we put our list]</p><p>Set markedDateShowIcon to true to show icon of markedDatesMap list.</p><p>markedDateShowIconMaxShown to 1 So it looks we have defined the color to date.</p><p>markedDateMoreShowTotal == null for not showing hidden events indicator</p><p>Now define a function markedDateIconBuilder to return event icon;</p><p>We can change the weekend days by using locale (If India you can use ‘en_in’).</p><p>Now we can use this _calendarCarouselNoHeader Widget anywhere we need the calendar. Thanks for reading. It’d be awesome to hear from you in the comments!</p><p>You can find link to GitHub repository <a href="https://github.com/naveenyadav15/Flutter-Examples/tree/calender">here</a>.</p><p><em>If you enjoyed this, feel free to buy me a coffee! ☕️ Your support keeps me motivated to share more. </em><a href="https://www.paypal.com/ncp/payment/ZXET7GZZB8EH6"><em>Link</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92238849e20c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>