mergeWith method

  1. @override
DataRefModel 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
DataRefModel mergeWith(
  BaseModel? other, {
  bool deepMerge = false,
}) {
  final a = toJson();
  final b = other?.toJson() ?? {};
  final data = (deepMerge ? mergeDataDeep(a, b) : {...a, ...b}) as Map;
  return DataRefModel.fromJson(data.cast());
}