flexi_formatter library

Classes

DateTimeUtils
A utility class for DateTime operations DateTime操作的实用工具类
FlexiFormatter
Global formatter configuration class 全局格式化器配置类

Enums

ExplicitDirection
https://unicode.org/reports/tr9 为何建议使用隔离字符?
RoundMode
Rounding mode 舍入模式
ShrinkZeroMode
Shrink zero mode for multiple consecutive zeros 多零收缩模式
StartOfWeek
An enumeration representing the start day of the week 表示一周开始日的枚举
TimeUnit
Time unit enumeration 时间单位枚举

Extensions

FlexiDateTimeExtension on DateTime
FlexiDateTimeFormatStringExt on String
FlexiDateTimeFormatterExt on DateTime
DateTime formatting extension DateTime格式化扩展 Test date: DateTime(2025, 5, 1, 12, 30, 45) 测试日期: DateTime(2025, 5, 1, 12, 30, 45)
FlexiDateTimeFormatterIntExt on int
FlexiNumberFormatStringExt on String
FlexiNumberFormatterBigIntExt on BigInt
FlexiNumberFormatterDecimalExt on Decimal
FlexiNumberFormatterDoubleExt on double
FlexiNumberFormatterIntExt on int

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的除法精度
HHmm → const String
Time format: HH:mm 时间格式: HH:mm
HHmmss → const String
Time format: HH:mm:ss 时间格式: HH:mm:ss
HHmmssSSS → const String
Time format: HH:mm:ss.SSS 时间格式: HH:mm:ss.SSS
maxGroupIntegerCounts → const int
Maximum group count 最大可分组计数
MMdd → const String
Date format with '-' separator: MM-dd 使用-分隔符的日期格式化: MM-dd
MMddHHmm → const String
Date and time format with '-' separator: MM-dd HH:mm 使用-分隔符的日期时间格式化: MM-dd HH:mm
MMddHHmmss → const String
Date and time format with '-' separator: MM-dd HH:mm:ss 使用-分隔符的日期时间格式化: MM-dd HH:mm:ss
mmssSSS → const String
Time format: mm:ss.SSS 时间格式: mm:ss.SSS
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
yyyyMM → const String
Date format with '-' separator: yyyy-MM 使用-分隔符的日期格式化: yyyy-MM
yyyyMMdd → const String
Date format with '-' separator: yyyy-MM-dd 使用-分隔符的日期格式化: yyyy-MM-dd
yyyyMMDDHHmm → const String
Date and time format with '-' separator: yyyy-MM-dd HH:mm 使用-分隔符的日期时间格式化: yyyy-MM-dd HH:mm
yyyyMMDDHHmmss → const String
Date and time format with '-' separator: yyyy-MM-dd HH:mm:ss 使用-分隔符的日期时间格式化: yyyy-MM-dd HH:mm:ss
yyyyMMDDHHmmssSSS → const String
Date and time format with '-' separator: yyyy-MM-dd HH:mm:ss.SSS 使用-分隔符的日期时间格式化: yyyy-MM-dd HH:mm:ss.SSS

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, ShrinkZeroMode? shrinkZeroMode, ShrinkZeroConverter? shrinkZeroConverter, 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 零收缩转换器函数类型, 将零的数量转换为字符串