Hi,
I don't know if there's a workaround for this.
In my project I have the case where one single class (form) is a combination of several other classes (model objects that reflect tables from the database).
I have for example these 2 models:
@freezed
class EquipmentBase with _$EquipmentBase {
const factory EquipmentBase({
required int id,
required String name,
}) = _EquipmentBase;
}
@freezed
class Equipment with _$Equipment {
const factory Equipment({
required int id,
required int type,
}) = _Equipment;
}
And this single form object:
@freezed
class EquipmentForm with _$EquipmentForm {
const factory EquipmentForm({
required int id,
required String name,
required int type,
}) = _EquipmentForm;
}
I'd like to be able to get an EquipmentForm (TARGET) based on both Equipment and EquipmentBase (SOURCES)
At the moment I just make a double conversion and combine manually the properties at the end:
- Convert EquipmentBase to EquipmentForm
- Convert Equipment to EquipmentForm
- Use copyWith() to combine both EquipmentForm objects
Is there anyway I can do this at the moment? Maybe through a custom converter or similar?
Thanks.
Hi,
I don't know if there's a workaround for this.
In my project I have the case where one single class (form) is a combination of several other classes (model objects that reflect tables from the database).
I have for example these 2 models:
And this single form object:
I'd like to be able to get an EquipmentForm (TARGET) based on both Equipment and EquipmentBase (SOURCES)
At the moment I just make a double conversion and combine manually the properties at the end:
Is there anyway I can do this at the moment? Maybe through a custom converter or similar?
Thanks.