FormatUtils class

Name: 格式化工具类 基于 intl Created by Fitem on 2023/7/7

Constructors

FormatUtils.new()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

formatInt(int num, [int digit = 2, String locale = 'en_US']) String
解析数字,转化为两位数,不足补0 num 数字 digit 保留位数,默认保留2位数 locale 地域 解析结果:1 -> 01
formatMoney(num num, [String pattern = moneyPattern, String locale = 'en_US']) String
解析货币数字 num 数字 pattern 格式化规则 locale 地域 解析结果:1000000 -> 1,000,000.00
formatPercent(num num, [String locale = 'en_US']) String
解析数字,转化为百分比 num 数字 locale 地域 解析结果:0.1234 -> 12.34%
formatPermillage(num num, [String locale = 'en_US']) String
解析数字,转化为千分比 num 数字 locale 地域 解析结果:0.1234 -> 123.4‰
formatPoint(num num, [int digit = 2, String locale = 'en_US']) String
解析小数点,默认保留两位小数 num 数字 digit 保留小数位数,默认保留2位小数 解析结果:1.234 -> 1.23
formatPointMax(num num, [int digit = 2, String locale = 'en_US']) String
解析小数点,默认最多保留两位小数,若尾数为0,则去掉 num 数字 digit 保留小数位数,默认保留2位小数 locale 地域 解析结果:1.20 -> 1.0

Constants

moneyIntPattern → const String
货币数字格式化-整数
moneyPattern → const String
货币数字格式化
moneyPointPattern → const String
货币数字格式化-小数点后2位