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
Hello, Im working with an abstract class, lets call it IModel:
abstract class IModel{
String getModelId();
}
And the freezed class that Implements it:
@freezed
class Model with _$Model implements IModel {
const Model._();
const factory Model({
required String id
}) = _Model;
factory Model.fromJson(Map<String, Object?> json) => _$ModelFromJson(json);
@override
String getModelId() {
return id;
}
}
Now, my issue comes when I have another class with freezed, that has a member of the IModel type like so:
@freezed
class OtherClass with _$OtherClass {
const factory OtherClass({
required List<IModel> models
}) = _OtherClass;
factory OtherClass.fromJson(Map<String, Object?> json) => _$OtherClassFromJson(json);
//I get an error when creating the fromJson here
}
I get an error on the "OtherClass" that says that I can't create the fromJson due to IModel, and I cant figure it out, any ideas on what I might be doing wrong?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, Im working with an abstract class, lets call it IModel:
And the freezed class that Implements it:
Now, my issue comes when I have another class with freezed, that has a member of the IModel type like so:
I get an error on the "OtherClass" that says that I can't create the fromJson due to IModel, and I cant figure it out, any ideas on what I might be doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions