custom_mapper
A powerful code generation package for creating type-safe mappers between domain objects and data transfer objects (DTOs) in Dart and Flutter applications.
Installation
Add both packages to your pubspec.yaml:
dependencies:
custom_mapper_annotation: ^0.0.4
dev_dependencies:
custom_mapper: ^0.0.8
build_runner: ^2.4.13
Usage
- Import the annotation package
- Annotate your DTO classes
- Run code generation
import 'package:custom_mapper_annotation/custom_mapper_annotation.dart';
@Mapper(domain: User, toDomain: true, toData: true)
class UserDto {
final String name;
final int age;
final String email;
const UserDto({
required this.name,
required this.age,
required this.email,
});
}
Then run:
dart run build_runner build
This will generate mapping extensions for your classes.
Libraries
- builder
- Builder configuration for the custom_mapper package.
- custom_mapper
- A powerful code generation package for creating type-safe mappers between domain objects and data transfer objects (DTOs) in Dart and Flutter applications.