copyWith method

  1. @override
FieldModel copyWith(
  1. BaseModel? other, {
  2. bool merge = false,
})
override

Returns a new copy of the BaseModel with the fields updated from the other BaseModel. If merge is true, the fields are merged, otherwise they are replaced.

Implementation

@override
FieldModel copyWith(BaseModel? other, {bool merge = false}) {
  final a = this.toJson();
  final b = other?.toJson() ?? {};
  final data0 = merge ? mergeDataDeep(a, b) : {...a, ...b};
  final data1 = letMapOrNull<String, dynamic>(data0);
  return FieldModel.fromJson(data1);
}