flutter-pre-caching

Preload fonts, images, animations, and startup data in Flutter and Flutter Web apps.

628|64|Updated Apr 22, 2025
One-click install
npx skills add https://github.com/evanca/flutter-ai-rules --skill flutter-pre-caching
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: flutter-pre-caching
Source: https://github.com/evanca/flutter-ai-rules/tree/main/skills/flutter-pre-caching
Command: npx skills add https://github.com/evanca/flutter-ai-rules --skill flutter-pre-caching

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Flutter apps often show jank, font swaps, blank images, and delayed first renders because assets load lazily at first use. This Skill provides guidance for pre-caching the right resources at startup so the first screens render smoothly without wasting memory on assets the user may never see.

Core Features & Use Cases

  • Font and image preloading: Use GoogleFonts.pendingFonts, precacheImage, and bundled font declarations to eliminate font swaps and image pop-in on first paint.
  • Animation and data warm-up: Preload Lottie and Rive compositions, local JSON config, and initial API requests before showing the home screen.
  • Flutter Web optimization: Combine HTML rel=preload hints with Flutter precacheImage, handle emoji font fallback, and configure renderer startup.
  • Use Case: When building a Flutter Web app whose landing screen shows a hero image, custom font, and emoji, use this Skill to preload exactly those assets in index.html and didChangeDependencies so the first frame renders without flicker.

Quick Start

Ask the agent to add startup pre-caching for the fonts, hero image, and initial API data on your Flutter app's first screen.

Frequently Asked Questions about flutter-pre-caching

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I preload images in Flutter before they are displayed?

Use precacheImage with an AssetImage or NetworkImage inside didChangeDependencies, passing the current context. This warms Flutter's in-memory image cache so the image renders instantly when the widget builds.

How to preload Google Fonts in a Flutter app?

Call GoogleFonts.pendingFonts with the list of font styles you need, typically in initState, and gate rendering with a FutureBuilder. For production, prefer bundling critical fonts as assets declared in pubspec.yaml.

Does precacheImage provide offline caching for network images?

No, precacheImage only warms Flutter's in-memory image cache and does not persist images to disk. For long-term disk caching of network images, use a package like cached_network_image.

Why do emojis cause rendering delays on Flutter Web?

Emojis can trigger font fallback downloads on the web, causing delayed renders, blank boxes, or font swaps on first paint. Either delay decorative emojis until after load or bundle and preload an emoji font like NotoColorEmoji.

What assets should I pre-cache on Flutter app startup?

Pre-cache only what the user will see in the next one to two screens: the logo, hero image, main font variants, small config files, and the first API request. Avoid preloading all product images, every font weight, or large animations not shown immediately.

How do I preload assets for Flutter Web in index.html?

Add link tags with rel=preload for critical fonts and images, using URLs like assets/assets/images/logo.png since Flutter serves declared assets under the assets path. Combine this with precacheImage in Dart to warm both the browser and Flutter caches.