<?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: Johnson</title>
    <description>The latest articles on DEV Community by Johnson (@johnson_flutter_dev).</description>
    <link>https://dev.to/johnson_flutter_dev</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4254997%2Fae00c251-f708-4807-9546-1e87dbb0549e.png</url>
      <title>DEV Community: Johnson</title>
      <link>https://dev.to/johnson_flutter_dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/johnson_flutter_dev"/>
    <language>en</language>
    <item>
      <title>How Flutter's Rendering Engine Works</title>
      <dc:creator>Johnson</dc:creator>
      <pubDate>Fri, 20 Nov 2026 12:13:46 +0000</pubDate>
      <link>https://dev.to/johnson_flutter_dev/how-flutters-rendering-engine-works-ao3</link>
      <guid>https://dev.to/johnson_flutter_dev/how-flutters-rendering-engine-works-ao3</guid>
      <description>&lt;h2&gt;
  
  
  The big idea
&lt;/h2&gt;

&lt;p&gt;Most UI frameworks hand your buttons and text to the operating system's built-in widgets. &lt;strong&gt;Flutter doesn't.&lt;/strong&gt; It draws every pixel itself, the way a game engine does. The OS gives Flutter a blank canvas, and Flutter paints everything on it: buttons, text, shadows, scrolling lists.&lt;/p&gt;

&lt;p&gt;That's why a Flutter app looks the same on every platform, and why Flutter needs its own rendering pipeline.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. The three layers of Flutter
&lt;/h2&gt;

&lt;p&gt;Think of Flutter as a three-storey building. Your code lives on the top floor, and each floor only talks to the one below it.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    A["Your app code (Dart)"] --&amp;gt; B
    subgraph B["Framework (Dart)"]
        B1["Material / Cupertino"]
        B2["Widgets"]
        B3["Rendering: layout and paint"]
        B4["Animation, Gestures, Painting"]
    end
    B --&amp;gt; C
    subgraph C["Engine (C++)"]
        C1["Dart runtime"]
        C2["Impeller / Skia graphics"]
        C3["Text layout"]
    end
    C --&amp;gt; D
    subgraph D["Embedder (platform code)"]
        D1["Window / surface"]
        D2["Input and vsync"]
        D3["Plugins"]
    end
    D --&amp;gt; E["OS and GPU"]&lt;/code&gt;&lt;/pre&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Written in&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Framework&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Dart&lt;/td&gt;
&lt;td&gt;Widgets, Material/Cupertino, animation, gestures, layout and paint logic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Engine&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;C++&lt;/td&gt;
&lt;td&gt;Runs Dart, rasterizes graphics (Impeller or Skia), lays out text, talks to the GPU&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Embedder&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Kotlin/Java, Swift/ObjC, C++&lt;/td&gt;
&lt;td&gt;Creates the window, passes in touches and vsync, hosts plugins&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  2. The three trees
&lt;/h2&gt;

&lt;p&gt;This is the most important idea in Flutter rendering. When you write widgets, Flutter actually maintains &lt;strong&gt;three parallel trees&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Analogy: building a house&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Widget = the blueprint.&lt;/strong&gt; A cheap paper description: "a wall, 3 metres, painted blue". You throw it away and draw a new one whenever something changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Element = the site manager.&lt;/strong&gt; They hold the blueprint, remember what's already built, and compare each new blueprint with the old one to decide what actually needs changing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RenderObject = the actual building.&lt;/strong&gt; The real, expensive structure that has a size, a position and knows how to paint itself.
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart LR
    subgraph W["Widget tree (blueprints)"]
        W1["Container"] --&amp;gt; W2["Padding"] --&amp;gt; W3["Text"]
    end
    subgraph E["Element tree (managers)"]
        E1["Element"] --&amp;gt; E2["Element"] --&amp;gt; E3["Element"]
    end
    subgraph R["RenderObject tree (buildings)"]
        R2["RenderPadding"] --&amp;gt; R3["RenderParagraph"]
    end
    W1 -.-&amp;gt; E1
    W2 -.-&amp;gt; E2
    W3 -.-&amp;gt; E3
    E2 -.-&amp;gt; R2
    E3 -.-&amp;gt; R3&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;Not every widget has a render object. &lt;code&gt;Container&lt;/code&gt; is just a composition of other widgets, so only the widgets that actually lay out or paint (like &lt;code&gt;Padding&lt;/code&gt; and &lt;code&gt;Text&lt;/code&gt;) create one.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tree&lt;/th&gt;
&lt;th&gt;Lifetime&lt;/th&gt;
&lt;th&gt;Job&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Widget&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Very short; rebuilt often&lt;/td&gt;
&lt;td&gt;Immutable configuration. Just data.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Element&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Long-lived&lt;/td&gt;
&lt;td&gt;The link. Knows its place in the tree, holds &lt;code&gt;State&lt;/code&gt;, decides whether to update or replace. Your &lt;code&gt;BuildContext&lt;/code&gt; &lt;em&gt;is&lt;/em&gt; the Element.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;RenderObject&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Long-lived&lt;/td&gt;
&lt;td&gt;The heavy work: layout, painting, hit-testing.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Why three trees?
&lt;/h3&gt;

&lt;p&gt;Because &lt;strong&gt;widgets are cheap and render objects are expensive&lt;/strong&gt;. When you call &lt;code&gt;setState&lt;/code&gt;, Flutter rebuilds the widgets, then each element compares the new widget with the old one:&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    A["setState called"] --&amp;gt; B["Widget rebuilt (new cheap object)"]
    B --&amp;gt; C{"Same type and same key as before?"}
    C -- yes --&amp;gt; D["Keep the Element and RenderObject. Just update their properties."]
    C -- no --&amp;gt; E["Throw away that subtree. Create new Elements and RenderObjects."]
    D --&amp;gt; F["Fast: e.g. only the color changes"]
    E --&amp;gt; G["Slower: full rebuild of that part"]&lt;/code&gt;&lt;/pre&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Hello'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;TextStyle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;isRed&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nc"&gt;Colors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;red&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Colors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When &lt;code&gt;isRed&lt;/code&gt; changes, a &lt;strong&gt;new &lt;code&gt;Text&lt;/code&gt; widget&lt;/strong&gt; is created, but the &lt;strong&gt;same &lt;code&gt;RenderParagraph&lt;/code&gt;&lt;/strong&gt; just gets a new color and repaints. Flutter rebuilds blueprints, not buildings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keys:&lt;/strong&gt; without keys, elements are matched by &lt;em&gt;position&lt;/em&gt;. When you reorder a list, the wrong &lt;code&gt;State&lt;/code&gt; can attach to the wrong item. A &lt;code&gt;Key&lt;/code&gt; says "match me by identity, not by position".&lt;/p&gt;




&lt;h2&gt;
  
  
  3. The rendering pipeline: one frame
&lt;/h2&gt;

&lt;p&gt;Every frame goes through the same stages, triggered by the screen's vsync signal.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    V["Vsync signal (an event on the event loop)"] --&amp;gt; A
    subgraph UI["UI thread (your Dart code)"]
        A["1. Animate: tickers update values"] --&amp;gt; B["2. Build: only dirty widgets rebuild"]
        B --&amp;gt; C["3. Layout: measure and position"]
        C --&amp;gt; D["4. Paint: record drawing commands into layers"]
        D --&amp;gt; E["5. Composite: send the layer tree to the engine"]
    end
    E --&amp;gt; F
    subgraph RT["Raster thread (C++)"]
        F["6. Rasterize: Impeller / Skia turns layers into GPU pixels"]
    end
    F --&amp;gt; G["Frame appears on screen"]&lt;/code&gt;&lt;/pre&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Step 0:&lt;/strong&gt; &lt;code&gt;setState&lt;/code&gt;, an animation or a scroll calls &lt;code&gt;scheduleFrame()&lt;/code&gt;. Nothing happens immediately; Flutter waits for the next vsync.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Animate:&lt;/strong&gt; &lt;code&gt;AnimationController&lt;/code&gt;s update their values for this frame.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build:&lt;/strong&gt; only widgets marked &lt;strong&gt;dirty&lt;/strong&gt; rebuild, not the whole app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layout:&lt;/strong&gt; sizes and positions are calculated (next section).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Paint:&lt;/strong&gt; render objects &lt;strong&gt;record commands&lt;/strong&gt; ("draw a rounded rect here"). No pixels yet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Composite:&lt;/strong&gt; the layer tree goes to the engine, and the UI thread is free again.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rasterize:&lt;/strong&gt; the raster thread turns commands into real pixels on the GPU.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  4. Layout: the golden rule
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Constraints go down. Sizes go up. Parent sets position.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;sequenceDiagram
    participant P as Parent
    participant C as Child
    P-&amp;gt;&amp;gt;C: Constraints: width 0 to 400, height 0 to 800
    Note over C: Child picks its own size within the limits
    C--&amp;gt;&amp;gt;P: My size: 300 x 50
    Note over P: Parent decides where to place the child
    P-&amp;gt;&amp;gt;P: Position child at (50, 100)&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;strong&gt;Analogy:&lt;/strong&gt; a manager tells an employee, "Your desk can be at most 2 metres wide." The employee picks a 1.5 m desk. The manager decides where in the office it goes. The employee never chooses their own position.&lt;/p&gt;

&lt;p&gt;This explains classic Flutter puzzles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why &lt;code&gt;Container(width: 100)&lt;/code&gt; sometimes fills the whole screen:&lt;/strong&gt; its parent gave it &lt;strong&gt;tight&lt;/strong&gt; constraints, so it had no choice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why you get "unbounded height" errors:&lt;/strong&gt; a &lt;code&gt;ListView&lt;/code&gt; inside a &lt;code&gt;Column&lt;/code&gt; receives infinite height constraints and can't pick a size.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Layout is a &lt;strong&gt;single pass&lt;/strong&gt; through the tree, which is why it's fast. &lt;strong&gt;Relayout boundaries&lt;/strong&gt; stop a change from spreading upward when a child's size can't affect its parent.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Paint and layers
&lt;/h2&gt;

&lt;p&gt;Painting doesn't create pixels. It records commands into &lt;strong&gt;pictures&lt;/strong&gt;, which are grouped into a &lt;strong&gt;layer tree&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    R["Root layer"] --&amp;gt; A["AppBar layer"]
    R --&amp;gt; B["Body layer"]
    B --&amp;gt; C["List item layers (RepaintBoundary)"]
    B --&amp;gt; D["Spinner layer (RepaintBoundary)"]
    D -.-&amp;gt; E["Spinner changes every frame: ONLY this layer repaints"]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;RepaintBoundary&lt;/code&gt;&lt;/strong&gt; gives a part of the UI its own layer. When something inside it changes, only that layer repaints, not the whole screen. Flutter adds these automatically in some places, such as list items and routes.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. The threads involved
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Thread&lt;/th&gt;
&lt;th&gt;Job&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Platform&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;OS main thread: receives touches, runs plugins and platform views&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;UI&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Runs &lt;strong&gt;your Dart code&lt;/strong&gt;: event loop, build, layout, paint&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Raster&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Turns the layer tree into GPU pixels&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;IO&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Decodes images and loads assets&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Flutter &lt;strong&gt;pipelines&lt;/strong&gt; frames: while the raster thread draws frame 1, the UI thread is already building frame 2.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;sequenceDiagram
    participant UI as UI thread
    participant RT as Raster thread
    participant S as Screen
    UI-&amp;gt;&amp;gt;UI: Build, layout, paint frame 1
    UI-&amp;gt;&amp;gt;RT: Layer tree for frame 1
    par Work in parallel
        RT-&amp;gt;&amp;gt;RT: Rasterize frame 1
    and
        UI-&amp;gt;&amp;gt;UI: Build, layout, paint frame 2
    end
    RT-&amp;gt;&amp;gt;S: Show frame 1
    UI-&amp;gt;&amp;gt;RT: Layer tree for frame 2
    RT-&amp;gt;&amp;gt;RT: Rasterize frame 2
    RT-&amp;gt;&amp;gt;S: Show frame 2&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;That gives you &lt;strong&gt;two places where jank can come from&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Jank source&lt;/th&gt;
&lt;th&gt;Cause&lt;/th&gt;
&lt;th&gt;Fix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;UI thread&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Slow Dart code, big rebuilds, heavy layout&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;const&lt;/code&gt; widgets, smaller widgets, isolates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Raster thread&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Expensive scene: &lt;code&gt;saveLayer&lt;/code&gt;, &lt;code&gt;Opacity&lt;/code&gt;, clipping, blurs, shadows&lt;/td&gt;
&lt;td&gt;Simplify effects, use &lt;code&gt;RepaintBoundary&lt;/code&gt; wisely&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Flutter DevTools' performance view shows both threads as separate bars, so you can see which one is slow.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. Impeller vs Skia
&lt;/h2&gt;

&lt;p&gt;The engine needs a graphics library to turn drawing commands into pixels.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Skia (original)&lt;/th&gt;
&lt;th&gt;Impeller (new default on iOS and modern Android)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Built for&lt;/td&gt;
&lt;td&gt;General 2D graphics (also used by Chrome)&lt;/td&gt;
&lt;td&gt;Flutter specifically&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shaders&lt;/td&gt;
&lt;td&gt;Compiled &lt;strong&gt;at runtime&lt;/strong&gt;, the first time an effect appears&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Precompiled at build time&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Result&lt;/td&gt;
&lt;td&gt;Possible stutter on first animations ("shader compilation jank")&lt;/td&gt;
&lt;td&gt;Smooth from the first frame&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GPU APIs&lt;/td&gt;
&lt;td&gt;OpenGL, Metal, Vulkan&lt;/td&gt;
&lt;td&gt;Metal (iOS), Vulkan (Android)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;As an app developer you rarely touch either directly. You just get smoother first frames with Impeller.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. A tap, end to end
&lt;/h2&gt;



&lt;pre data-lang="mermaid"&gt;&lt;code&gt;sequenceDiagram
    participant OS as OS / Platform thread
    participant UI as UI thread (Dart)
    participant RT as Raster thread
    participant GPU as GPU / Screen
    OS-&amp;gt;&amp;gt;UI: Touch event posted to event loop
    UI-&amp;gt;&amp;gt;UI: Hit-test render tree, find the button
    UI-&amp;gt;&amp;gt;UI: onTap runs, setState marks element dirty
    UI-&amp;gt;&amp;gt;OS: scheduleFrame (wait for vsync)
    OS-&amp;gt;&amp;gt;UI: Vsync event
    UI-&amp;gt;&amp;gt;UI: Animate, Build (dirty part only), Layout, Paint
    UI-&amp;gt;&amp;gt;RT: Layer tree
    RT-&amp;gt;&amp;gt;GPU: Rasterize and display
    Note over OS,GPU: All within ~16 ms at 60 Hz&lt;/code&gt;&lt;/pre&gt;



&lt;ol&gt;
&lt;li&gt;Your finger touches the screen, and the &lt;strong&gt;platform thread&lt;/strong&gt; receives it.&lt;/li&gt;
&lt;li&gt;The engine posts it to the &lt;strong&gt;UI thread&lt;/strong&gt; as an &lt;strong&gt;event&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Flutter &lt;strong&gt;hit-tests&lt;/strong&gt; the render tree ("which render object is under this point?").&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;onTap&lt;/code&gt; runs and calls &lt;code&gt;setState&lt;/code&gt;. The element is marked dirty and a frame is scheduled.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vsync&lt;/strong&gt; arrives: animate, then build, layout, paint and composite.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;raster thread&lt;/strong&gt; draws it on the GPU, and the updated UI appears.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  9. What this means for your everyday code
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Practice&lt;/th&gt;
&lt;th&gt;Why it helps internally&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;const&lt;/code&gt; widgets&lt;/td&gt;
&lt;td&gt;The same instance is reused, so Flutter skips rebuilding that subtree&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Small, split-up widgets&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;setState&lt;/code&gt; marks a smaller subtree dirty&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ListView.builder&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Only builds and lays out the visible items&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;Key&lt;/code&gt;s on reorderable lists&lt;/td&gt;
&lt;td&gt;Elements and &lt;code&gt;State&lt;/code&gt; match the right items&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;RepaintBoundary&lt;/code&gt; around frequently changing UI&lt;/td&gt;
&lt;td&gt;Only that layer repaints&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;FadeTransition&lt;/code&gt; / &lt;code&gt;AnimatedOpacity&lt;/code&gt; instead of animating &lt;code&gt;Opacity&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Avoids expensive &lt;code&gt;saveLayer&lt;/code&gt; work on the raster thread&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Heavy computation in isolates&lt;/td&gt;
&lt;td&gt;Keeps the UI thread inside the frame budget&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Quick summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Flutter &lt;strong&gt;draws every pixel itself&lt;/strong&gt; with its own engine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Three trees:&lt;/strong&gt; Widget (blueprint), Element (manager), RenderObject (real building).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Each frame:&lt;/strong&gt; vsync, animate, build, layout, paint, composite, then rasterize.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layout rule:&lt;/strong&gt; constraints go down, sizes go up, the parent sets the position.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Paint records commands&lt;/strong&gt;; the &lt;strong&gt;raster thread&lt;/strong&gt; turns them into pixels.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Jank&lt;/strong&gt; comes from either the &lt;strong&gt;UI thread&lt;/strong&gt; (your Dart code) or the &lt;strong&gt;raster thread&lt;/strong&gt; (expensive drawing).&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>flutter</category>
      <category>mobile</category>
      <category>programming</category>
      <category>ui</category>
    </item>
  </channel>
</rss>
