merge method Null safety

ButtonStyle merge(
  1. ButtonStyle? style

Returns a copy of this ButtonStyle where the non-null fields in style have replaced the corresponding null fields in this ButtonStyle.

In other words, style is used to fill in unspecified (null) fields this ButtonStyle.


ButtonStyle merge(ButtonStyle? style) {
  if (style == null) {
    return this;
  return copyWith(
    textStyle: textStyle ?? style.textStyle,
    backgroundColor: backgroundColor ?? style.backgroundColor,
    foregroundColor: foregroundColor ?? style.foregroundColor,
    overlayColor: overlayColor ?? style.overlayColor,
    shadowColor: shadowColor ?? style.shadowColor,
    surfaceTintColor: surfaceTintColor ?? style.surfaceTintColor,
    elevation: elevation ?? style.elevation,
    padding: padding ?? style.padding,
    minimumSize: minimumSize ?? style.minimumSize,
    fixedSize: fixedSize ?? style.fixedSize,
    maximumSize: maximumSize ?? style.maximumSize,
    iconColor: iconColor ?? style.iconColor,
    iconSize: iconSize ?? style.iconSize,
    side: side ?? style.side,
    shape: shape ?? style.shape,
    mouseCursor: mouseCursor ?? style.mouseCursor,
    visualDensity: visualDensity ?? style.visualDensity,
    tapTargetSize: tapTargetSize ?? style.tapTargetSize,
    animationDuration: animationDuration ?? style.animationDuration,
    enableFeedback: enableFeedback ?? style.enableFeedback,
    alignment: alignment ?? style.alignment,
    splashFactory: splashFactory ?? style.splashFactory,