smartstruct
1.4.0, released 4 years ago by an unverified publisher
A Dart bean mapper annotation processor for generating type-safe mappers.
What it does
Smartstruct is a code generator that creates type-safe bean mappers in Dart, inspired by MapStruct. It automates mapping properties between different model and entity classes.
AI-written summary of version 1.4.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to map data between models, DTOs, and domain entities
- You want compile-time type safety for object-to-object mapping
- You prefer annotation-driven code generation over manual mapping
Skip it when
- You prefer manual mapping without using build_runner
- Your project does not use objects that require mapping between layers
Strengths
- Type-safe object mapping at compile-time
- Supports nested bean mapping, lists, and custom function mappings
- Integrates well with build_runner and injectable
Weaknesses
- Requires running code generation via build_runner
- Manual workarounds needed for specific third-party libraries like freezed
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 0
Add smartstruct to dependencies and smartstruct_generator along with build_runner to dev_dependencies, then run build_runner.
part 'dogmapper.mapper.g.dart';
@Mapper()
abstract class DogMapper {
Dog fromModel(DogModel model);
}Alternatives
Packages that do the same job and could replace smartstruct.
- built_value
Choose built_value if you want immutable value classes with built-in serialization and builder patterns.
88Compare - freezed_annotation
Choose freezed if you primarily want union types, pattern matching, and immutable data classes with copyWith.
78Compare