evanca/flutter-ai-rules/flutter-pre-caching
Claude Code and agent skill by evanca/flutter-ai-rules
- community
Checking that the SKILL.md file is still in the repository.
Use when preloading fonts, asset/network images, Lottie/Rive animations, local JSON/config, warming initial API data, or optimizing Flutter Web startup.
Install
npx vskill@latest install evanca/flutter-ai-rules/flutter-pre-cachingSKILL.md
Pre-caching in Flutter and Flutter Web
Pre-caching helps avoid jank, loading flashes, font swaps, and delayed first renders.
The key rule:
Pre-cache only what the user will likely see in the next 1 to 2 screens.
Do not pre-cache the whole app. That can slow startup and waste memory.
1. Google Fonts
Runtime Google Fonts preloading
Use GoogleFonts.pendingFonts() to load the font variants before showing text.
Production recommendation
For production and offline support, prefer bundling critical fonts as assets.
Use it in the app theme:
2. Asset images
Use precacheImage for images that appear soon.
Then use the image normally:
3. Network images
Use precacheImage with NetworkImage.
Then use it normally:
Important: precacheImage warms Flutter’s in-memory image cache. It does not provide long-term offline caching.
For disk caching, use a package like cached_network_image:
Example:
4. Multiple image preloading
5. Waiting until images are ready
precacheImage returns a Future<void>, so you can wait before rendering the real UI.
[!NOTE]UsedidChangeDependencies, notinitState, when you needcontextforprecacheImage.
6. What should normally be pre-cached on app start?
Good candidates:
- App logo
- First screen hero image
- First visible background image
- Current user avatar
- First visible card/list images
- Main font variants
- Small local config files
- Translations needed for first paint
- First API request
- Lottie/Rive animation shown immediately
Bad candidates:
- All product images
- All gallery images
- All remote feed images
- All icons in the app
- All route images
- Every image from every screen
- Large animations not shown immediately
7. Practical app-start preloader
Usage:
With FutureBuilder:
8. Local JSON / config preloading
Useful for feature flags, local app config, mock data, translations, or onboarding content.
Example:
9. Initial API request warm-up
This is not pre-caching in the Flutter image-cache sense, but it is often the most useful startup optimization.
Example:
10. Lottie preloading
If the animation appears immediately, preload it.
Use this only for animations shown early. Avoid preloading many large animations on app start.
11. Rive preloading
Rather than triggering the asset load during a build (which causes jank), preload the RiveFile byte data in advance:
This ensures that the animation renders immediately upon widget mount.
12. Shader warm-up
Most apps do not need this. It can help if you have:
- Heavy custom painting
- Complex transitions
- Known animation jank
- Older rendering paths
Basic shape:
Then set it before runApp:
Use this only when profiling shows shader compilation jank.
13. Flutter Web: different mindset
On Flutter Web, think less:
- Pre-cache everything in memory
Think more:
- Make the browser download key files early
- Warm Flutter cache only for first-screen assets
- Avoid surprise font fallback downloads
- Avoid loading huge assets before first paint
14. Flutter Web image preload
For critical first-screen images, use both browser preload and Flutter precacheImage.
In web/index.html:
In Flutter:
Why both?
- HTML preload starts the browser download earlier.
precacheImagewarms Flutter's image cache.
15. Flutter Web network image preload
In web/index.html:
In Flutter:
Only do this for images the user is almost guaranteed to see.
16. Flutter Web font preload
Declare the font in pubspec.yaml:
Preload the critical font in web/index.html:
Use it in Flutter:
Usually preload:
- Regular
- Bold
- Maybe medium
Avoid preloading every weight and italic variant unless the first screen needs them.
17. Flutter Web and emojis
Emojis can trigger font fallback work.
Example:
On web, this can cause:
- Extra font download
- Delayed render
- Fallback font swap
- Blank boxes
- Different emoji style across platforms
18. Option 1: avoid emojis on first paint
Simple and effective:
Then show emojis after the app has loaded:
This is often the best option if emojis are decorative.
19. Option 2: bundle and preload an emoji font
Add the font to pubspec.yaml:
Preload it in web/index.html:
Use it where needed:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 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/flutter-pre-caching/SKILL.md
Popularity
- Repository stars
- 643
- Repository forks
- 66
- 7-day trend score
- 32
Stars and forks are for the whole GitHub repository, not this skill alone. 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/evanca/flutter-ai-rules/flutter-pre-caching)