entityfy_generator 2.0.0
entityfy_generator: ^2.0.0 copied to clipboard
Dart code generator that creates extension methods to map model classes to entity classes using annotations. Simplifies the implementation of toEntity() methods for clean data transformation between layers.
Entityfy Generator #
Code generator for the entityfy package. Automatically generates complete Entity classes, UI Model classes, and their mapping methods using the @Entityfy annotation.
Installation #
dependencies:
entityfy: ^2.0.0
dev_dependencies:
entityfy_generator: ^2.0.0
build_runner: ^2.4.9
Features #
- π― Dual Class Generation: Generate both Entity and UI Model classes from a single source
- π Complete Class Creation: Auto-generates constructors,
fromJson(), andtoJson()methods - π Bidirectional Mapping: Creates both
toEntity()andtoUiModel()extension methods - βοΈ Flexible Configuration: Configure what to generate with boolean flags
- π Smart Type Conversion: Intelligent handling of nested models, lists, and primitive types
- π‘οΈ Type-Safe Mapping: Full compile-time type checking and validation
- ποΈ Combined Output: All code generated in a single
.entityfy.g.dartfile - π DateTime Support: Automatic ISO8601 DateTime serialization
- π Nested Model Support: Recursive conversion of annotated nested models
Running the Generator #
# Generate code once
dart run build_runner build
# Watch for changes and rebuild automatically
dart run build_runner watch
# Clean previous builds
dart run build_runner clean