number library

Classes

FlexiFormatter
Global formatter configuration class 全局格式化器配置类

Enums

ExplicitDirection
https://unicode.org/reports/tr9 为何建议使用隔离字符?
RoundMode
Rounding mode 舍入模式
ShrinkZeroMode
Shrink zero mode for multiple consecutive zeros 多零收缩模式

Constants

defaultDecimalSeparator → const String
Default decimal separator 默认小数点分隔符
defaultGroupIntegerCounts → const int
Default group count for integer part 默认整数部分分组数量计数
defaultGroupIntegerSeparator → const String
Default group separator for integer part (thousand separator) 默认整数部分分组(千分位)分隔符
defaultPercentSign → const String
Default percent sign 默认百分比符号
defaultScaleOnInfinitePrecision → const int
Default scale for infinite precision Decimal division 无限精度Decimal的除法精度
maxGroupIntegerCounts → const int
Maximum group count 最大可分组计数
subscriptNegative → const String
Subscript negative sign 下角标的负号
subscriptNumerals → const List<String>
Subscript numerals: 12345₀₁₂₃₄₅₆₇₈₉₊₋ 下角标的数字符号12345₀₁₂₃₄₅₆₇₈₉₊₋
subscriptPositive → const String
Subscript positive sign 下角标的正号
superscriptNegative → const String
Superscript negative sign 上角标的负号
superscriptNumerals → const List<String>
Superscript numerals: 12345⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻ 上角标的数字符号12345⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻ Note: Due to Unicode standard design, ¹²³ (U+00B9, U+00B2, U+00B3) are from Latin-1 Supplement, while ⁰⁴⁵⁶⁷⁸⁹ (U+2070, U+2074-U+2079) are from Superscripts and Subscripts block. Some fonts may render them with slightly different baselines. This is expected behavior. 注意: 由于Unicode标准设计,¹²³ (U+00B9, U+00B2, U+00B3) 来自Latin-1 Supplement块, 而⁰⁴⁵⁶⁷⁸⁹ (U+2070, U+2074-U+2079) 来自Superscripts and Subscripts块。 某些字体可能以略微不同的基线渲染它们,这是预期的行为。
superscriptPositive → const String
Superscript positive sign 上角标的正号
uniFSI → const String
uniLRE → const String
Explicit directional embedding and override format characters (Embeddings & Overrides) 显式定向嵌入和覆盖格式字符(Embeddings & Overrides)
uniLRI → const String
Explicit directional isolate format characters (Isolates) 显式定向隔离格式字符(Isolates)
uniLRO → const String
uniPDF → const String
Pop directional formatting (end embedding/override) 嵌套/覆盖结束符
uniPDI → const String
Pop directional isolate (end isolate) 结束隔离区
uniRLE → const String
uniRLI → const String
uniRLO → const String

Properties

billion → Decimal
Decimal constant: 1,000,000,000 Decimal常量: 1,000,000,000
final
defaultExponentMaxDecimal → Decimal
Default maximum exponent decimal: 10^21 默认最大指数Decimal: 10^21
final
defaultExponentMinDecimal → Decimal
Default minimum exponent decimal: 10^-15 默认最小指数Decimal: 10^-15
final
fifty → Decimal
Decimal constant: 50 Decimal常量: 50
final
hundred → Decimal
Decimal constant: 100 Decimal常量: 100
final
hundredMillion → Decimal
Decimal constant: 100,000,000 Decimal常量: 100,000,000
final
million → Decimal
Decimal constant: 1,000,000 Decimal常量: 1,000,000
final
one → Decimal
Decimal constant: 1 Decimal常量: 1
final
tenBillion → Decimal
Decimal constant: 10,000,000,000 Decimal常量: 10,000,000,000
final
tenThousand → Decimal
Decimal constant: 10,000 Decimal常量: 10,000
final
thousand → Decimal
Decimal constant: 1,000 Decimal常量: 1,000
final
three → Decimal
Decimal constant: 3 Decimal常量: 3
final
trillion → Decimal
Decimal constant: 1,000,000,000,000 Decimal常量: 1,000,000,000,000
final
twentieth → Decimal
Decimal constant: 1/20 Decimal常量: 1/20
final
two → Decimal
Decimal constant: 2 Decimal常量: 2
final

Functions

formatAmount(Decimal? val, {int? precision, bool showSign = false, bool signFirst = false, RoundMode? roundMode, bool enableCompact = true, CompactConverter? compactConverter, bool cutInvalidZero = true, ShrinkZeroMode? shrinkZeroMode, ShrinkZeroConverter? shrinkZeroConverter, ExplicitDirection? direction, String prefix = '', String suffix = '', String? defIfZero, String defIfNull = '--'}) String
Format amount value 格式化数量值
formatNumber(Decimal? val, {int? precision, bool showSign = false, bool signFirst = false, RoundMode? roundMode, bool cutInvalidZero = false, bool enableCompact = false, CompactConverter? compactConverter, bool enableGrouping = false, String? groupSeparator, int? groupCounts, ShrinkZeroMode? shrinkZeroMode, ShrinkZeroConverter? shrinkZeroConverter, ExplicitDirection? direction, String prefix = '', String suffix = '', String? defIfZero, String defIfNull = '--'}) String
Format number with various options 格式化数字, 支持多种选项
formatPercentage(Decimal? val, {bool expandHundred = true, int? precision, bool showSign = false, bool signFirst = true, RoundMode roundMode = RoundMode.truncate, bool cutInvalidZero = false, bool enableGrouping = true, ExplicitDirection? direction, bool? percentSignFirst, String prefix = '', String suffix = '', String? defIfZero, String defIfNull = '--'}) String
Format percentage value 格式化百分比值
formatPrice(Decimal? val, {int? precision, bool showSign = false, bool signFirst = false, RoundMode roundMode = RoundMode.truncate, bool cutInvalidZero = true, bool enableGrouping = true, ShrinkZeroMode? shrinkZeroMode, ShrinkZeroConverter? shrinkZeroConverter, ExplicitDirection? direction, String prefix = '', String suffix = '', String? defIfZero, String defIfNull = '--'}) String
Format price value 格式化价格值
nonShrinkZeroConverter(int zeroCounts) String
Non-shrink zero converter 不进行零收缩转换器
simplifiedChineseCompactConverter(Decimal val) → (Decimal, String)
Simplified Chinese compact converter 简体中文精简转换器
thousandCompactConverter(Decimal val) → (Decimal, String)
Thousand compact converter 千分位精简转换器
traditionalChineseCompactConverter(Decimal val) → (Decimal, String)
Traditional Chinese compact converter 繁体中文精简转换器

Typedefs

CompactConverter = (Decimal, String) Function(Decimal value)
Compact converter function type, returns (converted value, unit) 精简转换器函数类型, 返回(转换后的值, 单位)
ShrinkZeroConverter = String Function(int zeroCounts)
Shrink zero converter function type, converts zero count to string 零收缩转换器函数类型, 将零的数量转换为字符串