Overview
The cached_annotation package provides annotations used by the Cached code generator to enable efficient, type-safe caching in Flutter applications. It works in conjunction with the Cached package and does not function independently. These annotations allow developers to mark classes and fields for automatic serialization, deserialization, and caching logic generation at compile time. This reduces boilerplate and improves performance by generating optimized cache handling code. The package supports all major platforms including Android, iOS, Web, macOS, Windows, and Linux.
Use cases
- Generating cached models from JSON
- Automating serialization/deserialization
- Optimizing data persistence
- Reducing manual boilerplate
- Enabling type-safe cache operations
- Improving app performance
Key features
- Compile-time code generation
- Type-safe caching
- Minimal runtime overhead
- Platform-agnostic
- Seamless integration with Cached
- Supports complex nested structures
Suitable for
- Flutter apps requiring persistent data
- Developers using Cached for state management
- Projects aiming to reduce boilerplate
- Teams prioritizing performance
- Apps with frequent data fetching
- Large-scale applications with complex models
Considerations
- Requires Cached package to be installed
- Code generation requires build_runner
- Not usable standalone
- May increase build time
- Limited to supported data types
- Dependent on annotation processing