getTextStyle method

TextStyle getTextStyle({
  1. @Deprecated('Use textScaler instead. ' 'Use of textScaleFactor was deprecated in preparation for the upcoming nonlinear text scaling support. ' 'This feature was deprecated after v3.12.0-2.0.pre.') double textScaleFactor = 1.0,
  2. TextScaler textScaler = TextScaler.noScaling,
})

The style information for text runs, encoded for use by dart:ui.

Implementation

ui.TextStyle getTextStyle({
  @Deprecated(
    'Use textScaler instead. '
    'Use of textScaleFactor was deprecated in preparation for the upcoming nonlinear text scaling support. '
    'This feature was deprecated after v3.12.0-2.0.pre.',
  )
  double textScaleFactor = 1.0,
  TextScaler textScaler = TextScaler.noScaling,
}) {
  assert(
    identical(textScaler, TextScaler.noScaling) || textScaleFactor == 1.0,
    'textScaleFactor is deprecated and cannot be specified when textScaler is specified.',
  );
  final double? fontSize = switch (this.fontSize) {
    null => null,
    final double size when textScaler == TextScaler.noScaling => size * textScaleFactor,
    final double size => textScaler.scale(size),
  };
  return ui.TextStyle(
    color: color,
    decoration: decoration,
    decorationColor: decorationColor,
    decorationStyle: decorationStyle,
    decorationThickness: decorationThickness,
    fontWeight: fontWeight,
    fontStyle: fontStyle,
    textBaseline: textBaseline,
    leadingDistribution: leadingDistribution,
    fontFamily: fontFamily,
    fontFamilyFallback: fontFamilyFallback,
    fontSize: fontSize,
    letterSpacing: letterSpacing,
    wordSpacing: wordSpacing,
    height: height,
    locale: locale,
    foreground: foreground,
    background: switch ((background, backgroundColor)) {
      (final Paint paint, _) => paint,
      (_, final Color color) => Paint()..color = color,
      _ => null,
    },
    shadows: shadows,
    fontFeatures: fontFeatures,
    fontVariations: fontVariations,
  );
}