Overview
Reflectable provides reflection capabilities in Dart through code generation, enabling runtime inspection and manipulation of types, fields, methods, and constructors. Instead of relying on built-in reflection (which is limited in Flutter), it uses 'capabilities' to define exactly which reflective operations are supported for specific classes. This approach ensures performance and compatibility across platforms like Android, iOS, Web, macOS, Windows, and Linux. It's ideal for frameworks and libraries needing dynamic behavior without sacrificing tree-shaking or performance.
Use cases
- Dynamic serialization/deserialization
- Runtime type inspection
- Generic framework development
- Code generation for APIs
- Plugin and library extensibility
Key features
- Code-generated reflection
- Capability-based operation control
- Cross-platform support
- Minimal runtime overhead
- Integration with build_runner
- Supports fields, methods, and constructors
Suitable for
- Framework developers
- Library authors
- Tools requiring dynamic type handling
- Apps using code generation
- Performance-sensitive applications
Considerations
- Requires build_runner and code generation
- Limited to explicitly declared capabilities
- Not suitable for runtime-only reflection
- Needs careful setup of reflectable annotations
- May increase build time slightly