mergeWith method

ReferencedModel mergeWith(
  1. BaseModel? other, {
  2. bool deepMerge = false,
})

Creates a copy of this instance, merging another model's fields into this model's fields.

Implementation

ReferencedModel mergeWith(
  BaseModel? other, {
  bool deepMerge = false,
}) {
  final a = toJson();
  final b = other?.toJson() ?? {};
  final data = (deepMerge ? mergeDataDeep(a, b) : {...a, ...b}) as Map;
  return ReferencedModel.fromJson(data.cast());
}