getFontStyle method

TextStyle getFontStyle({
  1. required double fontSize,
  2. FontWeight? fontWeight,
  3. Color? color,
  4. FontStyle? fontStyle,
  5. double? letterSpacing = 0,
  6. double? wordSpacing,
  7. double? height,
  8. String? fontFamily,
  9. TextDecoration? decoration,
})

Implementation

TextStyle getFontStyle({
  required double fontSize,
  FontWeight? fontWeight,
  Color? color,
  FontStyle? fontStyle,
  double? letterSpacing = 0,
  double? wordSpacing,
  double? height,
  String? fontFamily,
  TextDecoration? decoration,
}) {
  final resolvedFamily = fontFamily ?? UiFrameworkConfig.fontFamily;

  if (UiFrameworkConfig.fontStyleBuilder != null) {
    return UiFrameworkConfig.fontStyleBuilder!(
      fontSize: fontSize,
      fontWeight: fontWeight ?? FontWeight.w400,
      color: color,
      fontStyle: fontStyle,
      letterSpacing: letterSpacing,
      wordSpacing: wordSpacing,
      height: height,
      fontFamily: resolvedFamily,
      decoration: decoration,
    );
  }

  final base = TextStyle(
    fontSize: fontSize,
    fontWeight: fontWeight ?? FontWeight.w400,
    color: color,
    fontStyle: fontStyle,
    letterSpacing: letterSpacing,
    height: height,
    decoration: decoration,
    wordSpacing: wordSpacing,
  );

  if (resolvedFamily != null) {
    return base.copyWith(fontFamily: resolvedFamily);
  }

  return GoogleFonts.poppins(textStyle: base);
}