addFontSize static method

TextStyle addFontSize(
  1. TextStyle textStyle,
  2. String value
)

Creates a TextStyle to handle CSS font-size

Implementation

static TextStyle addFontSize(TextStyle textStyle, String value) {
  double number = 14.0;
  if (value.endsWith("px")) {
    number = double.parse(value.replaceAll("px", "").trim());
  } else if (value.endsWith("em")) {
    number *= double.parse(value.replaceAll("em", "").trim());
  }
  return textStyle.copyWith(fontSize: number);
}