mergeWith method

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

Returns a new copy of the BaseModel with the fields updated from the other BaseModel. Set deepMerge to true to merge nested objects.

Implementation

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