iamantoniodinuzzo/claude-flutter/asset-preload-init
Claude Code and agent skill by iamantoniodinuzzo/claude-flutter
- community
Checking that the SKILL.md file is still in the repository.
Fix first-frame asset pop-in in a Flutter app and audit its assets — inventories every file declared under `flutter: assets:`, maps each to the loader/cache that consumes it (SvgPicture.asset, Image.asset/AssetImage, engine registries like Flame, rootBundle, flutter_gen accessors, runtime-built paths), then generates only the warm-up that is actually needed (SVG via `SvgAssetLoader(path).loadBytes(null)` with errors handled at creation, overlapped with startup; context-based `precacheImage` for raster) and reports oversized and unused assets (report only, never deletes or resizes unasked). INIT when no warm-up exists, AUDIT when one does. Use when the user says \"precache assets\", \"warm up assets\", \"logo pop-in\", \"asset flicker on first frame\", \"precacheImage\", \"unused assets\", \"oversized images\", \"asset audit\", \"ottimizza gli asset\", or asks to speed up first-frame rendering of logos/icons.
Install
npx vskill@latest install iamantoniodinuzzo/claude-flutter/asset-preload-initSKILL.md
The same SKILL.md was published earlier as iamantoniodinuzzo/claude-flutter/asset-preload-init.
asset-preload-init
Runtime and resources
Use the current agent's native file, search, shell, and question tools; plain-text questions and direct sequential scans are valid fallbacks. Subagents are optional and require host permission. Bundled paths below are relative to this installed skill directory; application paths are relative to the target Flutter project. Resolve sibling skills through the installed skill registry (or sibling directories), never by assuming a skills/ folder in the application. If a required dependency is absent, name it and report the affected step as unavailable; never invent its rules or claim complete coverage.
Removes first-frame asset pop-in and audits asset hygiene in a Flutter app. Run phases in order. The warm-up is only a small part of the answer: most value comes from knowing which assets are really used, how each is loaded, and how big they are. Generate nothing for assets that do not need it.
Before coding, load the references in parallel:
references/loader-cache-matrix.mdreferences/size-and-dead-assets.md
Usage: /asset-preload-init [app-path]
Phase 0 — Intake & classify
- Melos: if
melos.yamlexists at the root, locate apps under the workspace packages. Ifapp-pathis missing and
several apps exist, ask which one (one question). Paths below are relative to the chosen app.
- Targets:
--platformarg >flutter.platformsinpubspec.yaml>all(same precedence as
audit-presentation-layer). State the result, e.g. Target platforms: web, android (from pubspec).
- INIT vs AUDIT: grep
lib/forSvgAssetLoader(,.loadBytes(null),precacheImage(,precacheAssets.
- none found → INIT
- found → AUDIT (report mismatches; never overwrite existing warm-up code)
- Read
pubspec.yaml:flutter_svgversion,flutter_gen/flutter_gen_runner,flame,flutter: assets:.
Phase 1 — Inventory and classify
- Expand
flutter: assets:(directories → files; quote paths with spaces). - For each file, find its consumers and map to the loader table (see
loader-cache-matrix.md):
| Consumer | Cache | Verdict | |
|---|---|---|---|
SvgPicture.asset | svg.cache | warm now / background | |
Image.asset / AssetImage | ImageCache | warm now (needs context) / background | |
Engine registry (Flame Images, sprite registry) | engine cache | already preloaded | |
rootBundle.load only | none | no cache | |
| no consumer found | — | unused (after runtime-path check) |
Also follow flutter_gen Assets.* accessors and runtime-built paths (prefix + enum .name + extension) — see size-and-dead-assets.md before concluding "unused".
- For raster files read pixel size; compute decoded size
w × h × 4; apply the hybrid oversize threshold. - Decide first-frame vs later: is the consumer reachable from the first route / app shell?
- Emit the table:
| File | Size | Px | Decoded | Consumers | First frame? | Loader/cache | Verdict |
|---|
Verdicts: warm now, background, already preloaded, no cache, unused, oversized.
Phase 2 — Decisions
Use the agent's question tool, or a plain-text question (recommendation first, max 1–2 blocking questions per round) for:
- Await vs background: await only first-screen assets; background the rest. On web, never await the full set.
- Raster warm-up location (only if raster first-frame assets exist): splash widget vs post-first-frame step.
- Oversized files: propose a resize command; never run it unasked.
- Unused files: report only by default; deletion is the user's call.
Skip questions whose inventory section is empty.
Phase 3 — Generate
Only for assets whose verdict is warm now / background.
- Cache-key precondition (SVG): for every consuming widget check there is no
theme:,colorMapper:,bundle:
argument and no DefaultSvgTheme ancestor. If any holds, skip that asset and explain (the warm-up would silently miss).
- Share paths: make the path constants public so the widget and the warm-up use the same string.
- SVG warm-up in
main():
``dart final warmUp = Future.wait([ for (final p in const [lightLogoPath, darkLogoPath]) SvgAssetLoader(p).loadBytes(null), ]).then<void>((_) {}, onError: (Object e) => debugPrint('[App] precache failed: $e')); // ... other startup work ... await warmUp; runApp(...); ``
- Use
SvgAssetLoader(p).loadBytes(null)directly — nosvg.cache.putIfAbsentwrapper. - Attach the error handler at creation, not at the
await. - Start early so it overlaps other startup work; await just before
runApp. - Warm both light and dark variants.
- Match the project's logging convention instead of
debugPrintif one exists.
- Raster: generate a context-based
precacheImage(AssetImage(path), context)helper only if raster first-frame
assets exist; call it post-first-frame or from the splash widget.
- Never generate for engine-preloaded assets or
rootBundle-only assets. If the inventory has nothing to warm, say
so and generate nothing.
- Oversized files that cannot be edited: suggest
cacheWidth/cacheHeightorResizeImageon the consumer.
Phase 4 — Verify
dart analyze(orflutter-analyze-targeted) on touched files.- Run existing widget tests of touched widgets.
- Manual checklist for the developer:
- First frame shows the logo with no pop-in — on web and mobile.
- Web network panel shows only the expected fetches before first paint.
- Sprites/markers still sharp after any resize.
Phase 5 — Summary
List: inventory table, files created/modified, assets deliberately not warmed (and why), oversized and unused findings (report only), and the manual checklist.
AUDIT branch
When a warm-up already exists, do not edit it. Report against the audit rules (same IDs as ../audit-presentation-layer/rules/CATALOG.md):
- ASSET-01 — first-frame
SvgPicture.asset/Image.assetwith no warm-up. - ASSET-02 — raster over the size budget.
- ASSET-03 — declared in pubspec but unreferenced (after runtime-path check).
- ASSET-04 — warm-up unsafe or ineffective: error not handled at creation, cache key cannot match the widget's
(theme/colorMapper/bundle/DefaultSvgTheme), or precacheImage used for an engine-managed cache.
Then offer targeted fixes; edit only what the user approves.
Notes
- Never delete or resize files without explicit confirmation.
- Related skills:
audit-presentation-layer(ASSET-01..04 on widget files),flutter-melos-workspace(multi-app repos),
flutter-analyze-targeted.
- Optional adjacent tip for non-precachable images (network, long lists):
image_fade'sImageFadecross-fade — see
loader-cache-matrix.md.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/asset-preload-init/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/iamantoniodinuzzo/claude-flutter/asset-preload-init)