reflection_factory
2.13.0, released 5 weeks ago by an unverified publisher
Allows Dart reflection and method proxies using code generation across all platforms.
What it does
Enables reflection capabilities for local and third-party classes through code generation and bridge annotations. It also supports class proxies to intercept method calls and tools for JSON decoding into entities.
AI-written summary of version 2.13.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need reflection features in Dart where native dart:mirrors is not supported.
- You need to reflect on third-party classes using bridge annotations.
- You want to create class proxies that intercept method calls.
Skip it when
- You want to avoid code generation steps during development.
- You do not need runtime reflection or dynamic method invocation.
Strengths
- Works across all Dart platforms where native mirrors are unavailable.
- Supports third-party classes through reflection bridges.
- Provides class proxies for intercepting method calls.
Weaknesses
- Requires maintaining a build_runner code generation step.
- Requires proper part directives in files where reflection is enabled.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 12
Add reflection_factory to dependencies and build_runner to dev_dependencies, then run dart run build_runner build.
import 'package:reflection_factory/reflection_factory.dart';
part 'some_source_file.reflection.g.dart';
@EnableReflection()
class User {
String? email;
User(this.email);
}
void main() {
var user = User('joe@mail.com');
var userReflection = user.reflection;
print('email: ${userReflection.field('email')?.get()}');
}Alternatives
Packages that do the same job and could replace reflection_factory.
- freezed
Code generation for immutable classes, tagged unions, and cloning without boilerplate.
96Compare - copy_with_extension_gen
Generate type‑safe copyWith extensions for annotated classes and record typedefs.
85Compare - json_annotation
Provides annotations for json_serializable to generate JSON (de)serialization code.
84Compare - source_gen
Source code generation builders and utilities for the Dart build system.
84Compare
Works with
Packages commonly used together with reflection_factory: ones it builds on, ones built on it, and its own family.
- analyzerreflection_factory depends on itPerforms static analysis of Dart code for tool integration and embedding.
- yamlreflection_factory depends on itA Dart library for parsing YAML documents into Dart data structures.
- pub_semverreflection_factory depends on itVersions and version constraints implementing pub's versioning policy.
- mimereflection_factory depends on itUtilities to resolve MIME types from file names, magic bytes, and to parse multipart streams.
- dart_stylereflection_factory depends on itProvides an API and CLI to format Dart source code automatically.
- source_spanreflection_factory depends on itStandard representation for source code locations, spans, and human-friendly error messages.
- loggingreflection_factory depends on itProvides configurable logging with levels and stream listeners for Dart apps.
- buildreflection_factory depends on itPackage for authoring build_runner compatible code generators.