CompactCodec class final

Converts compact values such as 1.2K or 3.4M.

Inheritance

Constructors

CompactCodec({required NumeralUnitSet unitSet, NumeralCodec<num>? style, String decimalSeparator = '.', int minFractionDigits = 0, int maxFractionDigits = 2, bool trimTrailingZeros = true, Rounding rounding = Rounding.halfUp, bool compactOverflow = true})
Creates a compact number codec.

Properties

compactOverflow → bool
Whether rounded values can move to the next larger unit.
final
decoder → Converter<String, num>
Converts display strings into numeric values.
no setterinherited
encoder → Converter<num, String>
Converts numeric values into display strings.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
inverted → Codec<String, num>
Inverts this.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
style → NumeralCodec<num>
Codec used for the numeric part before the compact unit.
final
unitSet → NumeralUnitSet
Unit set used by this codec.
final

Methods

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

Operators

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