textStyle function

TextStyle textStyle({
  1. double? size,
  2. double? wordSpacing,
  3. double? letterSpacing,
  4. Color? color,
  5. String? fontFamily,
  6. FontWeightEnum? weight,
  7. FontWeight? fontWeight,
  8. bool? softWrap,
  9. TextOverflow? overflow,
})

Implementation

TextStyle textStyle({
  double? size,
  double? wordSpacing,
  double? letterSpacing,
  Color? color,
  String? fontFamily,
  FontWeightEnum? weight,
  FontWeight? fontWeight,
  bool? softWrap,
  TextOverflow? overflow,
}) {
  assert(() {
    if (weight != null && fontWeight != null) {
      throw FlutterError(
        'weight and fontWeight can only be passed between the two, and cannot exist at the same time',
      );
    }
    return true;
  }());

  // get common font weight
  if (weight != null && fontWeight == null) {
    fontWeight = getFontWeight(weight);
  }

  return TextStyle(
    fontSize: size,
    color: color,
    fontFamily: fontFamily,
    fontWeight: fontWeight,
    wordSpacing: wordSpacing,
    letterSpacing: letterSpacing,
  );
}