Command Palette

Search for a command to run...

Назад к скиллам
скилл № 79842

flutter-internals

Use when the user asks about Flutter internals: widget/element/render object trees, BuildContext, constraints go down sizes go up, RenderBox, Impeller vs…

БесплатноБез исполняемых скриптов
j4flmaoот j4flmao★ 47 звёзд на GitHub

Установить flutter-internals в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Flutter Internals

Purpose

Flutter draws every pixel itself instead of wrapping OEM widgets. Understanding the three trees, the constraint-based layout protocol and the threads that produce a frame explains most "RenderFlex overflowed", "unbounded height" and jank problems, and tells you when a custom RenderObject is the right tool.

Agent Protocol

Trigger

"Flutter internals", "widget element render object", "BuildContext", "RenderObject", "layout constraints", "Impeller", "Skia", "raster thread", "layer tree", "Flutter engine", "platform views", "custom RenderBox".

Input Context

  • Flutter version and platform; renderer in use (Impeller/Skia)
  • Error message or DevTools timeline (UI vs raster thread times)
  • Widget subtree involved

Output Artifact

Explanation tied to the pipeline stage, plus the code fix or a custom render object. No file unless requested.

Response Format

Stage: {build | layout | paint | composite/raster | platform}
Cause: {mechanism}
Evidence: {error text / timeline numbers}
Fix: {code}

1. The Three Trees

Tree Object Lifetime Role
Widget immutable configuration (StatelessWidget, StatefulWidget, RenderObjectWidget) rebuilt often, cheap describes UI
Element ComponentElement, RenderObjectElement long-lived the instantiated tree; holds State, links widgets to render objects; BuildContext is the element
RenderObject RenderBox, RenderSliver long-lived layout, painting, hit testing
  • On rebuild, an element compares the new widget with the old: same runtimeType and key → update in place (canUpdate); otherwise the subtree is unmounted and recreated (state lost).
  • Keys preserve identity when children reorder (ValueKey), or move subtrees across the tree (GlobalKey — expensive, use sparingly).
  • InheritedWidget (and everything built on it: Theme.of, MediaQuery.of, Provider, Riverpod's scope) registers dependents so only they rebuild. Use specific accessors like MediaQuery.sizeOf(context) to depend on one aspect.

2. The Frame Pipeline

vsync → animate (tickers) → build (dirty elements) → layout → compositing bits → paint → semantics
     → layer tree submitted → raster thread rasterises with Impeller/Skia → GPU → display
  • UI thread (Dart root isolate) runs build/layout/paint and produces a layer tree; the raster thread turns it into GPU commands. At 60 Hz each has ~16 ms (8 ms at 120 Hz).
  • DevTools: if the UI bar is high → expensive build/layout/Dart code; if raster is high → expensive layers (saveLayer, clips, shaders, big images).

3. Layout Protocol

"Constraints go down, sizes go up, parent sets position":

  • Parent passes BoxConstraints(minW, maxW, minH, maxH); child picks a size within them; parent positions the child (child does not know its position).
  • Common errors:
    • Unbounded height — a ListView inside a Column: the column gives infinite max height. Fix: Expanded/Flexible around the list, or a fixed-height SizedBox.
    • RenderFlex overflowed — children's intrinsic sizes exceed the main axis; use Expanded, Flexible, Wrap, or scrolling.
    • Intrinsic sizing (IntrinsicHeight, IntrinsicWidth) runs extra layout passes — can be O(n²) in deep trees; avoid in lists.
  • Relayout boundaries (a render object whose size depends only on its constraints) stop layout invalidation from propagating upward.

4. Painting and Compositing

  • Render objects paint into layers; RepaintBoundary creates a separate layer so a frequently changing subtree repaints alone (and the rest is cached). Too many boundaries cost memory and compositing time.
  • saveLayer-triggering operations (opacity on groups, some ShaderMask/ColorFilter/clip combinations) allocate offscreen buffers; prefer per-primitive alpha and FadeTransition.
  • Text layout and image decoding are expensive; image decode happens off the UI thread but large images still cost raster/memory — decode at display size (cacheWidth).

5. Engine and Renderer

  • The engine (C++) hosts the Dart VM, text layout, the renderer and platform embedders (Android, iOS, web, Windows, macOS, Linux).
  • Impeller precompiles a small fixed set of shaders at build time, removing the runtime shader-compilation jank that Skia had. It is the default on iOS and on modern Android devices (Vulkan, with an OpenGL ES backend where needed); Flutter has been removing the Skia path on Android over recent releases — check the Impeller documentation for your version's fallback rules. Web uses CanvasKit/Skwasm (WebAssembly) builds.
  • Threads: platform (main) thread, UI thread, raster thread, I/O thread (per engine instance). Since Flutter 3.29 the Dart UI work runs on the platform main thread on iOS and Android (merged threads), which is what allows synchronous native calls through FFI; heavy Dart work therefore blocks platform events too.

6. Platform Integration

  • Platform chann
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл flutter-internals?

Use when the user asks about Flutter internals: widget/element/render object trees, BuildContext, constraints go down sizes go up, RenderBox, Impeller vs Skia, raster thread, platform views or the embedder. Explains the build-layout-paint pipeline to diagnose layout errors and jank. Not for app architecture or state management (use flutter-expertise).

Как установить скилл flutter-internals?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл flutter-internals запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить flutter-internals с