merge method Null safety

ResponsiveBreakpointSegment merge(
  1. ResponsiveBreakpointSegment responsiveBreakpointSegment
)

Merge overwrite operation.

Overwrite existing values with new values from responsiveBreakpointSegment. If the new segment isTag, do not overwrite existing segment values.

Implementation

ResponsiveBreakpointSegment merge(
    ResponsiveBreakpointSegment responsiveBreakpointSegment) {
  // Tag does not overwrite existing behavior.
  // Preserve existing values when merging.
  if (responsiveBreakpointSegment.isTag && !this.isTag)
    return this.copyWith(
        responsiveBreakpoint: this
            .responsiveBreakpoint
            .merge(responsiveBreakpointSegment.responsiveBreakpoint));
  // Overwrite existing values.
  return responsiveBreakpointSegment.copyWith(
      responsiveBreakpoint: this
          .responsiveBreakpoint
          .merge(responsiveBreakpointSegment.responsiveBreakpoint));
}