copyOnlyInherited method

Style copyOnlyInherited(
  1. Style child
)

Implementation

Style copyOnlyInherited(Style child) {
  FontSize? finalFontSize = FontSize.inherit(fontSize, child.fontSize);

  LineHeight? finalLineHeight = child.lineHeight != null
      ? child.lineHeight?.units == "length"
          ? LineHeight(child.lineHeight!.size! /
              (finalFontSize == null ? 14 : finalFontSize.value) *
              1.2)
          : child.lineHeight
      : lineHeight;

  return child.copyWith(
    backgroundColor: child.backgroundColor != Colors.transparent
        ? child.backgroundColor
        : backgroundColor,
    color: child.color ?? color,
    direction: child.direction ?? direction,
    display: display == Display.none ? display : child.display,
    fontFamily: child.fontFamily ?? fontFamily,
    fontFamilyFallback: child.fontFamilyFallback ?? fontFamilyFallback,
    fontFeatureSettings: child.fontFeatureSettings ?? fontFeatureSettings,
    fontSize: finalFontSize,
    fontStyle: child.fontStyle ?? fontStyle,
    fontWeight: child.fontWeight ?? fontWeight,
    lineHeight: finalLineHeight,
    letterSpacing: child.letterSpacing ?? letterSpacing,
    listStyleImage: child.listStyleImage ?? listStyleImage,
    listStyleType: child.listStyleType ?? listStyleType,
    listStylePosition: child.listStylePosition ?? listStylePosition,
    textAlign: child.textAlign ?? textAlign,
    textDecoration: TextDecoration.combine([
      child.textDecoration ?? TextDecoration.none,
      textDecoration ?? TextDecoration.none,
    ]),
    textShadow: child.textShadow ?? textShadow,
    whiteSpace: child.whiteSpace ?? whiteSpace,
    wordSpacing: child.wordSpacing ?? wordSpacing,
    maxLines: child.maxLines ?? maxLines,
    textOverflow: child.textOverflow ?? textOverflow,
    textTransform: child.textTransform ?? textTransform,
  );
}