getTextStyle method

TextStyle? getTextStyle(
  1. TagflowNode element,
  2. TagflowStyle? resolvedStyle,
  3. BuildContext context
)

Get the text style for a given element

Implementation

TextStyle? getTextStyle(
  TagflowNode element,
  TagflowStyle? resolvedStyle,
  BuildContext context,
) {
  if (element.isTextNode) {
    return null;
  }
  var textStyle = resolvedStyle?.textStyleWithColor;

  // Apply text scale factor directly to fontSize to avoid compounding
  // in nested elements
  if (resolvedStyle?.textScaleFactor != null && textStyle != null) {
    final currentFontSize =
        textStyle.fontSize ??
        DefaultTextStyle.of(context).style.fontSize ??
        14.0;
    textStyle = textStyle.copyWith(
      fontSize: currentFontSize * resolvedStyle!.textScaleFactor!,
    );
  }

  return textStyle;
}