<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Deadloq</title>
    <description>The latest articles on DEV Community by Deadloq (@deadloq_7e074852ed029afbc).</description>
    <link>https://dev.to/deadloq_7e074852ed029afbc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3709504%2Fc7f596be-753b-420f-9577-509697187814.png</url>
      <title>DEV Community: Deadloq</title>
      <link>https://dev.to/deadloq_7e074852ed029afbc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/deadloq_7e074852ed029afbc"/>
    <language>en</language>
    <item>
      <title>Title: I thought I broke Flutter: Why my UI wouldn't update (and the "Aha!" moment)</title>
      <dc:creator>Deadloq</dc:creator>
      <pubDate>Tue, 13 Jan 2026 17:23:26 +0000</pubDate>
      <link>https://dev.to/deadloq_7e074852ed029afbc/title-i-thought-i-broke-flutter-why-my-ui-wouldnt-update-and-the-aha-moment-15oe</link>
      <guid>https://dev.to/deadloq_7e074852ed029afbc/title-i-thought-i-broke-flutter-why-my-ui-wouldnt-update-and-the-aha-moment-15oe</guid>
      <description>&lt;p&gt;When I first started building Flutter apps, I kept wondering why my counter wouldn’t update when I pressed a button. The variable was changing in the code, but the screen stayed frozen at zero.&lt;/p&gt;

&lt;p&gt;I spent hours staring at the screen. I thought I broke the framework.&lt;/p&gt;

&lt;p&gt;That’s when I learned about State Management the hard way. If you've ever felt like Flutter is "ignoring" your code, this guide is for you.&lt;/p&gt;

&lt;h3&gt;
  
  
  The "Aha!" Moment: What is State?
&lt;/h3&gt;

&lt;p&gt;Think of State as your app’s memory. It’s the data that determines what users see right now.&lt;/p&gt;

&lt;p&gt;The items in a shopping cart? State.&lt;/p&gt;

&lt;p&gt;A checked box? State.&lt;/p&gt;

&lt;p&gt;That counter that refused to move for me? State.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stateless vs. Stateful (The "Photo" vs. "Mirror" Analogy)
&lt;/h2&gt;

&lt;p&gt;On Dev.to, we often see people overcomplicate this. Here is how I finally understood it:&lt;/p&gt;

&lt;p&gt;This is the function that changed everything for me. When you call setState(), you aren't just changing a variable; you are screaming at Flutter: "HEY! SOMETHING CHANGED! REBUILD THE UI!"&lt;/p&gt;

&lt;p&gt;Dart&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
// The mistake I made:&lt;br&gt;
onPressed: () {&lt;br&gt;
  counter++; // The variable changes, but the screen stays 0.&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;// The fix:&lt;br&gt;
onPressed: () {&lt;br&gt;
  setState(() {&lt;br&gt;
    counter++; // Now Flutter knows to repaint the screen.&lt;br&gt;
  });&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;br&gt;
`&lt;/p&gt;

&lt;h2&gt;
  
  
  3 Mistakes That Nearly Made Me Quit
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Changing variables outside setState(): The most common beginner trap.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Forgetting to dispose() controllers: I caused a massive memory leak in my first project because I didn't clean up my TextEditingController. Always dispose your controllers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using setState() for EVERYTHING: It’s great for local state (like a single form field), but if you try to manage your entire app’s login status with it, your code will become "spaghetti."&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Ephemeral State vs. App State
&lt;/h2&gt;

&lt;p&gt;In 2026, we have amazing tools like Riverpod and Bloc, but the official Flutter docs make a great distinction that I live by:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Ephemeral State: "I’m only using this data on this screen." (Use  setState)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;App State: "I need this data everywhere (e.g., User Profile)."   (Use a State Manager)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What was the first thing that confused you when learning Flutter? For me, it was definitely the "Stateful vs Stateless" split. Let’s discuss in the comments!&lt;/p&gt;

&lt;p&gt;This is an excerpt from my deep-dive series on Flutter. You can find the full, interactive To-Do App tutorial over at &lt;a href="https://deadloq.com/state-management-in-flutter/" rel="noopener noreferrer"&gt;Deadloq&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>beginners</category>
      <category>statemanagement</category>
    </item>
  </channel>
</rss>
