mergeObject method

  1. @override
IBaseObject mergeObject(
  1. IBaseObject? item
)
override

Implementation

@override
IBaseObject mergeObject(IBaseObject? item) {
  if (item == null) return this;

  Map<String, dynamic> thisUserMap = toJson();
  Map<String, dynamic> mergeUserMap = item.toJson();

  thisUserMap.forEach((key, value) {
    if (mergeUserMap[key] != null) {
      if (mergeUserMap[key] is String) {
        if ((mergeUserMap[key] as String).isNotEmpty) {
          thisUserMap[key] = mergeUserMap[key];
        }
      } else {
        thisUserMap[key] = mergeUserMap[key];
      }
    }
  });

  return fromJson(thisUserMap);
}