merge method

  1. @nonVirtual
  2. @override
ShapeBorderDto<ShapeBorder> merge(
  1. covariant ShapeBorderDto<ShapeBorder>? other
)
override

Merges this object with other, returning a new object of type T.

Implementation

@nonVirtual
@override
ShapeBorderDto merge(ShapeBorderDto? other) {
  if (other == null) return this;

  if (runtimeType == other.runtimeType) {
    return mergeBorder(other);
  }
  final thisBorder = this;
  if (thisBorder is BorderRadiusOutlinedBorderDto &&
      other is BorderRadiusOutlinedBorderDto) {
    if (other is RoundedRectangleBorderDto) {
      final thisBorder = this as BorderRadiusOutlinedBorderDto;

      return RoundedRectangleBorderDto(
        borderRadius: thisBorder.borderRadius,
        side: thisBorder.side,
      ).merge(other);
    }

    if (other is BeveledRectangleBorderDto) {
      final thisBorder = this as BorderRadiusOutlinedBorderDto;

      return BeveledRectangleBorderDto(
        borderRadius: thisBorder.borderRadius,
        side: thisBorder.side,
      ).merge(other);
    }

    if (other is ContinuousRectangleBorderDto) {
      final thisBorder = this as BorderRadiusOutlinedBorderDto;

      return ContinuousRectangleBorderDto(
        borderRadius: thisBorder.borderRadius,
        side: thisBorder.side,
      ).merge(other);
    }
  } else if (this is OutlinedBorderDto && other is OutlinedBorderDto) {
    final thisBorder = this as OutlinedBorderDto;
    if (other is CircleBorderDto) {
      // no need to add remainnig value as a is not a CircleBorderDto
      return CircleBorderDto(side: thisBorder.side).merge(other);
    } else if (other is StadiumBorderDto) {
      return StadiumBorderDto(side: thisBorder.side).merge(other);
    }
  }

  throw UnimplementedError(
    'Merging $runtimeType and $runtimeType is not implemented. Please implement it!',
  );
}