Is there any AutoMapper package for a flutter (like in c#)?
Example:
we are mapping the Entity to EntityModel.
mapper = Mapper();
Entity = Entity();
EntityModel = mapper(Entity );
Is there any AutoMapper package for a flutter (like in c#)?
Example:
we are mapping the Entity to EntityModel.
mapper = Mapper();
Entity = Entity();
EntityModel = mapper(Entity );
i don't think so, there is nothing like C# mapper in dart, but you can check this lib.
let me know if this is what you want.
This package might fit your needs, smartstruct , if you look at the example they provide:
class Dog {
final String breed;
final int age;
final String name;
Dog(this.breed, this.age, this.name);
}
class DogModel {
final String breed;
final int age;
final String name;
DogModel(this.breed, this.age, this.name);
}
// dogmapper.dart
part 'dogmapper.mapper.g.dart';
@Mapper()
abstract class DogMapper {
Dog fromModel(DogModel model);
}
Then any custom mappings or explicit maps you can add attributes:
@Mapper()
class DogMapper {
@Mapping(source: 'dogName', target: 'name')
Dog fromModel(DogModel model);
}