toFontSpec method

String toFontSpec()

Converts a PickerFont to a font spec description, a shorthand string that can describe a font. Examples of font specs: "Roboto:400", "Merriweather:700i", "Archivo Narrow:200i".

Implementation

String toFontSpec() {
  String fontWeightString = fontWeight.toString();
  String fontSpec =
      "$fontFamily:${fontWeightString.substring(fontWeightString.length - 3)}";
  return fontStyle == FontStyle.italic ? "${fontSpec}i" : fontSpec;
}