getTextStyle method
Implementation
TextStyle? getTextStyle(BuildContext? context,
{double? height, Color? backgroundColor}) {
var textFont = font ??
TDTheme.of(context).fontBodyLarge ??
Font(size: 16, lineHeight: 24);
var stylePackage = package;
var styleFontFamily = style?.fontFamily ?? fontFamily?.fontFamily;
var realFontWeight = style?.fontWeight ?? fontWeight;
// Flutter 3.0之后,iOS w500之下字体不生效,需要替换字体
if (PlatformUtil.isIOS &&
(styleFontFamily == null || styleFontFamily.isEmpty) &&
realFontWeight != null &&
realFontWeight.index <= FontWeight.w500.index) {
stylePackage = null;
styleFontFamily = 'PingFang SC';
}
return TextStyle(
inherit: style?.inherit ?? true,
color: style?.color ?? textColor,
/// 不使用系统本身的背景色,因为系统属性存在中英文是,会导致颜色出现阶梯状
backgroundColor: backgroundColor,
fontSize: style?.fontSize ?? textFont.size,
fontWeight: style?.fontWeight ?? fontWeight ?? textFont.fontWeight,
fontStyle: style?.fontStyle,
letterSpacing: style?.letterSpacing,
wordSpacing: style?.wordSpacing,
textBaseline: style?.textBaseline,
height: height ?? style?.height ?? textFont.height,
leadingDistribution: style?.leadingDistribution,
locale: style?.locale,
foreground: style?.foreground,
background: style?.background,
shadows: style?.shadows,
fontFeatures: style?.fontFeatures,
decoration: style?.decoration ??
(isTextThrough! ? TextDecoration.lineThrough : TextDecoration.none),
decorationColor: style?.decorationColor ?? lineThroughColor,
decorationStyle: style?.decorationStyle,
decorationThickness: style?.decorationThickness,
debugLabel: style?.debugLabel,
fontFamily: styleFontFamily,
fontFamilyFallback: style?.fontFamilyFallback,
package: stylePackage,
);
}