How sidrao2006/dynamic_cached_fonts works
Project type and purpose
• This is a Flutter/Dart library package (dynamic_cached_fonts) whose sole responsibility is to dynamically download web-hosted font files, cache them locally, and register them in the Flutter engine on demand.
• It also provides an example multi-platform Flutter app to demonstrate usage, plus a full test suite.
File structure
• Top‐level configuration: .github/, .gitignore, pubspec.yaml, CI/workflow manifests, Docker setup under dev/docker/.
• lib/: the core package code
• dynamic_cached_fonts.dart – public exports and entry points
• src/raw_dynamic_cached_fonts.dart – abstract base for low-level methods
• src/utils.dart – shared utilities
• example/: a complete Flutter app (Android, iOS, Web, macOS, Linux, Windows) showing how to use the library
• test/: unit and mock tests for API correctness
• doc/: demo images
README for additional insights
• The package exposes two main APIs: synchronous (load(), cacheFont(), etc.) and streamed (loadStream(), cacheFontStream()).
• Internally it:
a. Downloads font bytes from an HTTP(S) URL or gs:// Firebase storage
b. Caches files on local storage (with TTL and size limits)
c. Loads the font into the Flutter engine via the engine registry
d. Emits progress and item-count events on a Dart Stream
• Extensibility point: override RawDynamicCachedFonts to swap out network or cache implementation.
Detail without overcomplication
• Both synchronous (load, cacheFont) and streamed (loadStream, cacheFontStream) paths if space permits
• extensibility hook (RawDynamicCachedFonts) so readers can see where to plug in custom logic