formatPrice function
String
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 = '--',
Format price value 格式化价格值
This is a convenience function that wraps formatNumber with price-specific defaults:
- Trailing zeros removed by default (
cutInvalidZero= true) - Grouping enabled by default (
enableGrouping= true) - Truncate rounding mode by default (
roundMode= RoundMode.truncate)
这是一个便捷函数,使用价格特定的默认值包装 formatNumber:
- 默认删除尾部零 (
cutInvalidZero= true) - 默认启用分组 (
enableGrouping= true) - 默认截断舍入模式 (
roundMode= RoundMode.truncate)
Implementation
String 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 = '--',
}) {
return formatNumber(
val,
precision: precision,
showSign: showSign,
signFirst: signFirst,
roundMode: roundMode,
cutInvalidZero: cutInvalidZero,
enableGrouping: enableGrouping,
shrinkZeroMode: shrinkZeroMode,
shrinkZeroConverter: shrinkZeroConverter,
direction: direction,
prefix: prefix,
suffix: suffix,
defIfZero: defIfZero,
defIfNull: defIfNull,
);
}