deserialize method
Rational
deserialize(
- Serializers serializers,
- Object serialized, {
- FullType specifiedType = FullType.unspecified,
override
Deserializes serialized
.
serialized
is a boolean, an integer, a double or a String.
Use serializers
as needed for nested deserialization. Information about
the type being deserialized is provided in specifiedType
.
Implementation
@override
Rational deserialize(Serializers serializers, Object serialized,
{FullType specifiedType = FullType.unspecified}) {
final num = serialized as int;
final rawNum = num.toString();
final fineNum = rawNum.padRight(fractionDigits + 1, '0');
final whole = fineNum.advSubString(0, -fractionDigits);
final decimal = fineNum.advSubString(-fractionDigits, fineNum.length);
return Rational.parse('$whole.$decimal');
}