flutter-pre-caching

Featured

Use when preloading fonts, asset/network images, Lottie/Rive animations, local JSON/config, warming initial API data, or optimizing Flutter Web startup.

Data & Documents 619 stars 60 forks Updated today MIT

Install

View on GitHub

Quality Score: 95/100

Stars 20%
93
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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. ```dart import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class ExampleSimple extends StatefulWidget { const ExampleSimple({super.key}); @override State<ExampleSimple> createState() => _ExampleSimpleState(); } class _ExampleSimpleState extends State<ExampleSimple> { late final Future<List<void>> googleFontsPending; @override void initState() { super.initState(); googleFontsPending = GoogleFonts.pendingFonts([ GoogleFonts.poppins(), GoogleFonts.montserrat(fontStyle: FontStyle.italic), ]); } @override Widget build(BuildContext context) { final pushButtonTextStyle = GoogleFonts.poppins( textStyle: Theme.of(context).textTheme.headlineMedium, ); final counterTextStyle = GoogleFonts.montserrat( fontStyle: FontStyle.italic, textStyle: Theme.of(context).textTheme.displayLarge, ); return FutureBuilder<List<void>>( future: googleFontsPending, builder: (context, snapshot) { if (snapshot.connectionState != Connectio...

Details

Author
evanca
Repository
evanca/flutter-ai-rules
Created
1 years ago
Last Updated
today
Language
Shell
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category