copyOnlyInherited method

Style copyOnlyInherited(
  1. Style child
)

Implementation

Style copyOnlyInherited(Style child) {
  FontSize? finalFontSize = child.fontSize != null ?
    fontSize != null && child.fontSize?.units == "em" ?
      FontSize(child.fontSize!.size! * fontSize!.size!) : child.fontSize
    : fontSize != null && fontSize!.size! < 0 ?
      FontSize.percent(100) : fontSize;
  LineHeight? finalLineHeight = child.lineHeight != null ?
    child.lineHeight?.units == "length" ?
      LineHeight(child.lineHeight!.size! / (finalFontSize == null ? 14 : finalFontSize.size!) * 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,
    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,
  );
}