toStringAsGlyph method

String toStringAsGlyph()

If possible, this method converts this Fraction instance into an unicode glyph string.

A 'glyph' (or 'number form') is an unicode character that represents a fraction. For example, the glyph for "1/7" is ⅐. Only a very small subset of fractions have a glyph representation.

final fraction = Fraction(1, 7);
final str = fraction.toStringAsGlyph() // "⅐"

If the conversion is not possible, a FractionException object is thrown. You can use the isFractionGlyph getter to determine whether this fraction can be converted into an unicode glyph or not.

Implementation

String toStringAsGlyph() {
  if (_valuesToGlyphs.containsKey(this)) {
    return _valuesToGlyphs[this]!;
  }

  throw FractionException(
    'This fraction ($this) does not have an unicode fraction glyph!',
  );
}