<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mobile on Simple Enough Blog</title><link>https://blog-dev.simpleenough.net/tags/mobile/</link><description>Recent content in Mobile on Simple Enough Blog</description><generator>Hugo</generator><language>en</language><lastBuildDate>Tue, 15 Jul 2025 09:24:42 +0200</lastBuildDate><atom:link href="https://blog-dev.simpleenough.net/tags/mobile/index.xml" rel="self" type="application/rss+xml"/><item><title>Optimizing Flutter Performance: build(), keys, and const Widgets</title><link>https://blog-dev.simpleenough.net/blog/optimisationflutter/</link><pubDate>Tue, 15 Jul 2025 09:24:42 +0200</pubDate><guid>https://blog-dev.simpleenough.net/blog/optimisationflutter/</guid><description>&lt;p>This article proposes performance improvements by focusing on three fundamental aspects:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>The build() cycle&lt;/strong>&lt;/li>
&lt;li>&lt;strong>Keys&lt;/strong>&lt;/li>
&lt;li>&lt;strong>Const widgets&lt;/strong>&lt;/li>
&lt;/ul>
&lt;hr>




&lt;h2 id="i-the-build-cycle-understanding-to-optimize" class="heading">I. The build() cycle: understanding to optimize&lt;a href="#i-the-build-cycle-understanding-to-optimize" aria-labelledby="i-the-build-cycle-understanding-to-optimize">
&lt;!-- &lt;i class="fas fa-link anchor">&lt;/i> -->
 &lt;svg class="svg-inline--fa fas fa-link anchor" fill="currentColor" aria-hidden="true" role="img" viewBox="0 0 640 512">&lt;use href="#fas-link">&lt;/use>&lt;/svg>&amp;nbsp;
 &lt;/a>
&lt;/h2>
&lt;p>The &lt;strong>build()&lt;/strong> process is at the core of rendering in Flutter. When a state changes or a widget is rebuilt, the &lt;strong>build()&lt;/strong> method is called. Mismanaging this method can cause significant slowdowns.&lt;/p>




&lt;h3 id="a-when-is-build-triggered" class="heading">A. When is build() triggered?&lt;a href="#a-when-is-build-triggered" aria-labelledby="a-when-is-build-triggered">
&lt;!-- &lt;i class="fas fa-link anchor">&lt;/i> -->
 &lt;svg class="svg-inline--fa fas fa-link anchor" fill="currentColor" aria-hidden="true" role="img" viewBox="0 0 640 512">&lt;use href="#fas-link">&lt;/use>&lt;/svg>&amp;nbsp;
 &lt;/a>
&lt;/h3>
&lt;ol>
&lt;li>During the first widget creation.&lt;/li>
&lt;li>When calling &lt;strong>setState()&lt;/strong>.&lt;/li>
&lt;li>When a parent widget is rebuilt.&lt;/li>
&lt;/ol>




&lt;h3 id="b-techniques-to-reduce-the-build-impact" class="heading">B. Techniques to reduce the build() impact&lt;a href="#b-techniques-to-reduce-the-build-impact" aria-labelledby="b-techniques-to-reduce-the-build-impact">
&lt;!-- &lt;i class="fas fa-link anchor">&lt;/i> -->
 &lt;svg class="svg-inline--fa fas fa-link anchor" fill="currentColor" aria-hidden="true" role="img" viewBox="0 0 640 512">&lt;use href="#fas-link">&lt;/use>&lt;/svg>&amp;nbsp;
 &lt;/a>
&lt;/h3>
&lt;ol>
&lt;li>&lt;strong>Use const in the constructor&lt;/strong>: Creates immutable instances.&lt;/li>
&lt;li>&lt;strong>Break down the build&lt;/strong>: Split the UI into subcomponents to reduce the impact zone.&lt;/li>
&lt;li>&lt;strong>Avoid heavy calculations in build()&lt;/strong>: Delegate tasks to pre-computed functions or separate methods.&lt;/li>
&lt;/ol>
&lt;p>&lt;strong>Example: Optimization with subcomponents&lt;/strong>&lt;/p></description></item></channel></rss>