flutter-caching
Comprehensive caching and performance optimization for Flutter apps across multiple data types and platforms.
- Provides decision logic to select appropriate caching mechanisms: in-memory,
shared_preferencesfor key-value pairs, SQLite for relational data, file system for large blobs, and image caching for network images - Includes stream-based offline-first repository pattern that yields cached data first, then fetches and updates from the network
- Covers Android FlutterEngine pre-warming and caching to reduce Flutter initialization latency in hybrid apps
- Optimizes widget rendering, image caching, and scrolling performance using
ScrollCacheExtentobjects and strict GPU memory constraints - Enforces SQL injection prevention via parameterized queries and validates performance anti-patterns like unnecessary
saveLayer()calls and widget equality overrides
flutter-caching-and-performance
Goal
Implements advanced caching, offline-first data persistence, and performance optimization strategies in Flutter applications. Evaluates application requirements to select and integrate the appropriate local caching mechanism (in-memory, persistent, file system, or on-device databases). Configures Android-specific FlutterEngine caching to minimize initialization latency. Optimizes widget rendering, image caching, and scrolling performance while adhering to current Flutter API standards and avoiding expensive rendering operations.
Instructions
1. Evaluate and Select Caching Strategy (Decision Logic)
Analyze the user's data retention requirements using the following decision tree to select the appropriate caching mechanism:
- Is the data temporary and only needed for the current session?
- Yes: Use In-memory caching.
- Is the data small, simple key-value pairs (e.g., user preferences)?
- Yes: Use
shared_preferences.
- Yes: Use
- Is the data large, relational, or requires complex querying?
- Yes: Use On-device databases (e.g.,
sqflite). Proceed to Step 3.
- Yes: Use On-device databases (e.g.,
- Is the data large binary files, custom documents, or JSON blobs?
- Yes: Use File system caching (
path_provider). Proceed to Step 2.
- Yes: Use File system caching (
- Is the data network images?
- Yes: Use Image caching (
cached_network_imageor customImageCache). Proceed to Step 6.
- Yes: Use Image caching (
- Is the goal to reduce Android Flutter UI warm-up time?
More from flutter/skills
flutter-building-layouts
Builds Flutter layouts using the constraint system and layout widgets. Use when creating or refining the UI structure of a Flutter application.
10.6Kflutter-architecting-apps
Architects a Flutter application using the recommended layered approach (UI, Logic, Data). Use when structuring a new project or refactoring for scalability.
10.4Kflutter-animating-apps
Implements animated effects, transitions, and motion in a Flutter app. Use when adding visual feedback, shared element transitions, or physics-based animations.
9.6Kflutter-managing-state
Manages application and ephemeral state in a Flutter app. Use when sharing data between widgets or handling complex UI state transitions.
9.6Kflutter-theming-apps
Customizes the visual appearance of a Flutter app using the theming system. Use when defining global styles, colors, or typography for an application.
9.5Kflutter-implementing-navigation-and-routing
Handles routing, navigation, and deep linking in a Flutter application. Use when moving between screens or setting up URL-based navigation.
9.3K