PercentCodec class final

Converts ratios to and from percentage strings.

Inheritance

Constructors

PercentCodec({String symbol = '%', num scale = 100, bool spaceBeforeSymbol = false, bool requireSymbol = true, NumeralCodec<num>? style, String decimalSeparator = '.', int minFractionDigits = 0, int maxFractionDigits = 2, bool trimTrailingZeros = true, Rounding rounding = Rounding.halfUp})
Creates a percentage codec.

Properties

decoder → Converter<String, double>
Converts display strings into numeric values.
no setterinherited
encoder → Converter<double, String>
Converts numeric values into display strings.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
inverted → Codec<String, double>
Inverts this.
no setterinherited
requireSymbol → bool
Whether parsing requires symbol.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scale → num
Multiplier applied when formatting and parsing.
final
spaceBeforeSymbol → bool
Whether a space is inserted before symbol.
final
style → NumeralCodec<num>
Codec used for the numeric part before the percent symbol.
final
symbol → String
Symbol appended after the formatted number.
final

Methods

decode(String encoded) → double
Alias for parse.
inherited
encode(double input) → String
Alias for format.
inherited
format(num value) → String
Formats value into a display string.
override
fuse<R>(Codec<String, R> other) → Codec<double, R>
Fuses this with other.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse(String input) → double
Parses input and returns the numeric value.
override
toString() → String
A string representation of this object.
inherited
tryParse(String input) → double?
Parses input, returning null instead of throwing FormatException.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited