【发布时间】:2023-01-18 22:59:36
【问题描述】:
我想为我的班级实施 copyWith() 方法。由于它继承了类,我得到了错误:
被覆盖的成员。
我的基础模型
class BaseData { int id; String? createdAt, updatedAt; BaseData({this.id = 0, this.createdAt, this.updatedAt}); BaseData copyWith( {int? id, String? createdAt, String? updatedAt}) { return BaseData( CreatedAt: createdAt ?? this.createdAt, ID: id ?? this.id, UpdatedAt: updatedAt ?? this.updatedAt); } }我还有另一个扩展到我的
BaseData模型的课程class QcData extends BaseData{ String name; QcData ({this.name =""}); @override QcData copyWith({ String? name }){ return QcData(name: name ?? this.name); } }如何为我的模型类创建
copyWith()方法?提前致谢。
【问题讨论】: