You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Hi, at the moment, no. We would like to support this case with normal classes. (not for sealed/freezed, reasons similar to #148).
The implementation could be done for N input classes to 1 output, probably as a new MapTypeMultiple or something like that. But in the near future, I don't think we will have enough time to implement that.
You are, however, free to take the initiative if you'd like to!
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.
The text was updated successfully, but these errors were encountered: