Fraction.fromGlyph constructor
Fraction.fromGlyph(
- String value
Returns an instance of Fraction if value
has a glyph that represents a
fraction.
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. Some correct examples are:
Fraction.fromString("⅐") // 1/7
Fraction.fromString("⅔") // 2/3
Fraction.fromString("⅞") // 7/8
If value
doesn't represent a fraction glyph, a FractionException
object is thrown.
Implementation
factory Fraction.fromGlyph(String value) {
if (_glyphsToValues.containsKey(value)) {
return _glyphsToValues[value]!;
}
throw FractionException(
'The given string ($value) does not represent a valid fraction glyph!',
);
}