FLUTTER ECOSYSTEM

reflectable

Reflection support based on code generation, using 'capabilities' to specify which operations to support, on which objects. This is the run-time part of reflectable.

Latest version
5.2.3
30-day downloads
13.8K
Likes
186
Pub points
160

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

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
Supported platformsAndroidiOSWebmacOSWindowsLinux

Install package

flutter pub add reflectable

Categories

Source repository

Related projects