flutter-pre-caching
FeaturedUse 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
Quality Score: 95/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
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
AI & Automation Listed
flutter-google-fonts
Applying fonts using google_fonts
0 Updated 6 days ago
noory-code API & Backend Listed
flutter-persistence
Design or review Flutter local persistence, caching, offline behavior, schema evolution, and secure-data boundaries. Use for preferences, files, SQLite, or an existing database package; route remote transport to flutter-networking.
0 Updated today
thiennc-tesoglobal AI & Automation Listed
flutter-svg
SVG vector image rendering
0 Updated 6 days ago
noory-code