toString method

  1. @override
String toString()
inherited

Converts this GoogleFontsVariant to a Google Fonts API specific variant name string.

The following table shows how these variant strings convert: weight: 400, style: normal -> 'regular' weight: 400, style: italic -> 'italic' weight: 700, style: normal -> '700' weight: 700, style: italic -> '700italic'

See GoogleFontsVariant.toString for the inverse function.

Implementation

@override
String toString() {
  final fontWeightString =
      fontWeight.index == 3 ? '' : (fontWeight.index + 1) * 100;
  final fontStyleString = fontStyle
      .toString()
      .replaceAll('FontStyle.', '')
      .replaceFirst(_normal, fontWeight.index == 3 ? _regular : '');
  return '$fontWeightString$fontStyleString';
}