flutter-performance
/flutter-performance
Mierzy wydajność Fluttera w trybie profilowania przez DevTools, ogranicza przebudowy i pracę poza wątkiem UI oraz pilnuje budżetu klatki 16 ms.
- Autor
- Dee9975 ↗
- Repozytorium
- cc-skills-flutter ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 05.11.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 05.11.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Mierzy wydajność Fluttera w trybie profilowania przez DevTools, ogranicza przebudowy i pracę poza wątkiem UI oraz pilnuje budżetu klatki 16 ms.
Oryginalny opis (EN)
Flutter performance optimization — measuring in profile mode with DevTools (Performance, CPU profiler, Memory, rebuild counts), frame budget (16ms/8ms), reducing rebuilds (const, narrow selectors, splitting widgets, ValueListenableBuilder), lazy lists, RepaintBoundary, avoiding saveLayer (Opacity, ClipRRect, ShaderMask), image decoding (cacheWidth, precacheImage), shader jank and Impeller, moving work off the UI isolate, startup time, app size (--analyze-size, deferred imports), and memory leaks. Use when the app janks, scrolls poorly, starts slowly, uses too much memory, or when reviewing cod
Jak działa
- Measure first
- Rebuilds (UI thread)
- Lists
- Painting (raster thread)
- Images
- CPU work
- Startup
- App size
- Memory
Podgląd SKILL.md
--- name: flutter-performance description: "Flutter performance optimization — measuring in profile mode with DevTools (Performance, CPU profiler, Memory, rebuild counts), frame budget (16ms/8ms), reducing rebuilds (const, narrow selectors, splitting widgets, ValueListenableBuilder), lazy lists, RepaintBoundary, avoiding saveLayer (Opacity, ClipRRect, ShaderMask), image decoding (cacheWidth, precacheImage), shader jank and Impeller, moving work off the UI isolate, startup time, app size (--analyze-size, deferred imports), and memory leaks. Use when the app janks, scrolls poorly, starts slowly, uses too much memory, or when reviewing code for performance." license: MIT metadata: author: Matiss Kalnins version: "0.5.0" --- **Persona:** You measure before optimizing. Debug-mode performance means nothing, so every claim is checked in profile mode on a real (preferably low-end) device. ## Measure first 1. Run `flutter run --profile` on a physical device. Debug mode is many times slower, and the simulator isn't representative. 2. Open DevTools → **Performance**. Look for red frames. Each frame has a UI-thread budget (build/layout) and a raster-thread budget (paint/composite) of ~16ms at 60Hz, or ~8ms at 120Hz. 3. **UI thread slow** → too much build/layout work, or Dart computation. **Raster thread slow** → expensive painting (saveLayer, big images, clips, shadows). 4. Enable "Track widget rebuilds" to find widgets that rebuild more than they should. 5. Fix the biggest offender, then measure again. ## Rebuilds (UI thread) - Use `const` widgets. They're canonicalized and skipped during rebuilds. - **Lift ownership, narrow subscriptions.** State lives in the state layer, never in widget `State` (see `flutter-state-management`). Watch it as close as possible to where each value is displayed: self-connected components watch one provider each, and screens stay layout shells, so a change rebuilds only that component. Rows and sections below it stay `const`-friendly and cheap. Never "fix" rebuilds by moving state back into a `StatefulWidget`. - Select narrowly: `ref.watch(provider.select((s) => s.count))`, `context.select<Cart, int>((c) => c.count)`, `BlocSelector`. - Use `ValueListenableBuilder` / `ListenableBuilder` / `AnimatedBuilder` and pass a static `child:` so only the changing part rebuilds. - Don't create objects that trigger rebuilds of their consumers in `build` (new `Future`s for a `FutureBuilder`, new streams, new controllers). Create them once in `initState` or in the state layer. - Use `MediaQuery.sizeOf`/`paddingOf` etc. instead of `MediaQuery.of` (otherwise the widget rebuilds when the keyboard opens). ## Lists - Always use builder constructors (`ListView.builder`, `SliverList.builder`) for long lists. Never `Column` + `map` for hundreds of items, and never `shrinkWrap: true` on big lists. - Give fixed-height rows `itemExtent` / `prototypeItem`. - Keep item widgets cheap. Precompute formatting (dates, currency) in the model layer, not in `build`. ## Painting (raster thread) - Avoid `Opacity` on large or animated subtrees. Use `AnimatedOpacity`/`FadeTransition`, or put the alpha in the color (`color.withValues(alpha: 0.5)`). - Clipping costs: `Clip.hardEdge` < `Clip.antiAlias` < `Clip.antiAliasWithSaveLayer`. Use rounded `BoxDecoration` with `borderRadius` instead of `ClipRRect` where possible. - `ShaderMask`, `ColorFilter`, and `BackdropFilter` trigger `saveLayer`. Use them sparingly, especially in scrolling content. - Wrap independently animating regions (a spinner, a ticker) in `RepaintBoundary` so they don't repaint their neighbours. Verify with "Highlight repaints". Don't sprinkle it everywhere, since each boundary costs memory. - Impeller (the default renderer on iOS and Android) removes most first-run shader-compilation jank. If you still see jank on the first animation, profile it before you reach for workarounds. ## Images - Decode at display size: `Image.network(url, cacheWidth: (width * devicePixelRatio).round())`, or `ResizeImage`. Decoding a 4000px photo into a 100px avatar wastes memory and time. - Use `cached_network_image` for network images in lists. - `precacheImage` hero or above-the-fold images in `didChangeDependencies`. - Prefer vector assets (`flutter_svg`, or compiled `vector_graphics`) for icons, and WebP/AVIF for photos. ## CPU work Anything over ~4ms on the UI isolate (parsing large JSON, filtering big lists, image manipulation, crypto) moves to `Isolate.run` / `compute` (see `dart-async`). ## Startup - Keep `main()` minimal. Await only what's needed for the first frame, and defer the rest (analytics, remote config) until after `runApp`. - Show something useful immediately. Use a native splash (`flutter_native_splash`) instead of a Dart splash screen with artificial delays. - Measure with `flutter run --profile --trace-startup`. ## App size - Run `flutter build apk --analyze-size` (or `appbundle`/`ios`) and open the result in DevTools → App Size. - Remove unused packages and assets. Compress images. Use `--split-debug-info` + `--obfuscate` for release builds. - On web, use deferred imports (`import "..." deferred as feature;`) to split rarely used features into separate bundles. ## Memory - Leaks are almost always undisposed controllers, uncancelled subscriptions, or closures that capture a `State`/`BuildContext` held by a long-lived object. - DevTools → Memory: take a heap snapshot, navigate away and back, take another, and diff the two. Look for `State` objects that should be gone. - `package:leak_tracker` (built into `flutter_test`) can catch undisposed objects in widget tests.
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · Dee9975/cc-skills-flutter | 90 | MIT |
| thienqo/flutter-skills | 100 | BSD-3-Clause |
| HoangNguyen0403/agent-skills-standard | 100 | MIT |
| evolplus/talos | 100 | Apache-2.0 |
| thiennc-tesoglobal/flutter-skills | 100 | BSD-3-Clause |
| zakariaf/flutter-skills | 100 | MIT |
| Albaylar/Mobile-Development-Kit | 90 | MIT |
Migawka bazy z 13.11.2026 · wersja paczki 4719a967277f (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100flutter-performance-profiling
Diagnozuje jank, gubienie klatek i wolny start aplikacji Flutter przez DevTools timeline, tryb profile, podział raster i UI, shader jank i trace startu, a potem naprawia konkretną przyczynę. - 85flutter-core:flutter-performance
Optymalizuje aplikacje Flutter pod kątem szybkości, pamięci i rozmiaru, a także analizuje zacięcia i współbieżność przez narzędzia profilowania. - 100flutter-devtools
Pomaga profilować CPU, śledzić wycieki pamięci, sprawdzać drzewa widgetów i podglądać ruch sieciowy we Flutter DevTools. - 100performance
Stosuje reguły wydajności Flutter: konstruktory const, RepaintBoundary, konstruktory builder dla list, rozmiar cache obrazów i wyłączanie pracy z metod build. - 90Android Performance
Mierzy i poprawia wydajność aplikacji Android na telefonie: start, płynność, pamięć, profile bazowe i pracę wątku głównego. - 100memory-profiler-setup
Prawdopodobnie konfiguruje narzędzia do profilowania pamięci w ramach testów wydajności.